Jump to content


Photo

FormTemplateProcessor with Page Fieldtype


  • Please log in to reply
11 replies to this topic

#1 vitor

vitor

    Jr. Member

  • Members
  • PipPip
  • 25 posts
  • 6

  • LocationPortugal

Posted 21 March 2012 - 12:14 PM

Hi guys,

I'm trying to create a front end form using the FormTemplateProcessor with Page Fieldtype to create some selectable and radio elements, everything is working great,

The only issue I'm having and I've searched everywhere is that, when I submit the form the values from the select and radios on the email sent come as id's and not the title of those pages.

is there any way I could just grab the titles for the select and radio buttons? Or is there any better way to achieve this?

Thanks

Attached Thumbnails

  • Screen Shot 2012-03-21 at 5.14.04 PM.png


#2 vitor

vitor

    Jr. Member

  • Members
  • PipPip
  • 25 posts
  • 6

  • LocationPortugal

Posted 22 March 2012 - 08:48 AM

Ok,

I've managed to resolve this using the Module Fieldtype Select (AKA Drop Down) here: http://processwire.c...-aka-drop-down/ this way I just created a new Select field and add the required options.

Thanks guys for the Module.

Best

#3 ryan

ryan

    Hero Member

  • Administrators
  • 5,773 posts
  • 3122

  • LocationAtlanta, GA

Posted 22 March 2012 - 11:55 AM

Thanks for the follow-up on the solution you found for this.

#4 bitmatix

bitmatix

    Jr. Member

  • Members
  • PipPip
  • 12 posts
  • 1

Posted 18 August 2012 - 09:08 AM

Hi guys,

I'm trying to build an "advanved search" form depending on the idea of the "FormTemplateProcessor" and i also have some trouble with "InputfieldPage", because I need to modify the options, that appear in the select field. Is there any chance to "filter" the pages, which goes into the "InputfieldPage" before the field gets rendered?

Thanks!!!

#5 slkwrm

slkwrm

    Sr. Member

  • Members
  • PipPipPipPip
  • 248 posts
  • 66

Posted 18 August 2012 - 03:14 PM

bitmatix, have a look at your Page field's Input tab and two options on it:

Custom selector to find selectable pages
Custom PHP code to find selectable pages

Cheers.

#6 bitmatix

bitmatix

    Jr. Member

  • Members
  • PipPip
  • 12 posts
  • 1

Posted 20 August 2012 - 07:55 AM

bitmatix, have a look at your Page field's Input tab and two options on it:

Custom selector to find selectable pages
Custom PHP code to find selectable pages

Cheers.


Thanks a lot slkwrm, that's what I was looking for :-)

Now I have the problem, that I can't set the "class" attribute of the generated "select" tag. It only works for normal textfields. Any idea?

#7 slkwrm

slkwrm

    Sr. Member

  • Members
  • PipPipPipPip
  • 248 posts
  • 66

Posted 23 August 2012 - 04:46 PM

bitmax, not sure what you mean :huh: Could you explain in more detail?

#8 bitmatix

bitmatix

    Jr. Member

  • Members
  • PipPip
  • 12 posts
  • 1

Posted 26 August 2012 - 06:54 AM

bitmax, not sure what you mean :huh: Could you explain in more detail?


I want to do the following:

// get the collection of inputs that can populate this page's fields
$inputfields = $this->page->getInputfields();
foreach ($inputfields as $inputfield) {
	 $inputfield->setAttribute('class', 'span4');
	 $form->add($inputfield);
}

It seems like this only works for text inputfields, but not for "InputfieldPage" fields.

#9 Soma

Soma

    Hero Member

  • Moderators
  • 3,194 posts
  • 1749

  • LocationSH, Switzerland

Posted 26 August 2012 - 07:11 AM

Still really hard to understand what your need is. Studying your posts and code I think you are having a page with fields you output as as form on frontend, and one is a page field that will generate a select menu? Now you want to add class="span4" to all inputfields and also to the select menu or only to the option tags?

Are you using the Formtemplate processor module or your own code? How do your full code look or how are you rendering the inputfields and what is the result you desire?

@somartist | modules created | support me, flattr my work flattr.com


#10 bitmatix

bitmatix

    Jr. Member

  • Members
  • PipPip
  • 12 posts
  • 1

Posted 26 August 2012 - 07:18 AM

@Soma: Thank you for your fast replay!

I'm using a (own) modified version of the FormTemplateProcessor module and my code looks almost the same as in the original module. I want to add the "class" attribute to the "select" tag, not to the "option" tags.

#11 Soma

Soma

    Hero Member

  • Moderators
  • 3,194 posts
  • 1749

  • LocationSH, Switzerland

Posted 26 August 2012 - 08:15 AM

It's not possible in a convenient way, because the page field is special and not working the same as a text field. It has it's own method of adding the inputfield. So a check would be needed to look for if the inputfield is of type InputfieldPage and then do different code to set attribute for it's inputfield. But since the methods in the InputfieldPage are protected it isn't possible to do the following example:


foreach ($inputfields as $inputfield) {
  if($inputfield instanceof InputfieldPage){
    $inputfield->getInputfield()->setAttribute('class','span3'); // will fail cause method is protected
  } else {
    $inputfield->setAttribute('class', 'span4');
  }
  $form->add($inputfield);
}

InputfieldPage.module #101

protected function getInputfield() {

If Ryan could make it change to something it could be accessed the above code would work. I don't see any other way right now.


So, for now you could do a regex replace script to parse the returned html string from ->render() before outputting. Not simple if you don't know.

But, here's the most simple way using jQuery.

$('select[id^=Inputfield]').addClass('span4');

Voila.

@somartist | modules created | support me, flattr my work flattr.com


#12 ryan

ryan

    Hero Member

  • Administrators
  • 5,773 posts
  • 3122

  • LocationAtlanta, GA

Posted 27 August 2012 - 07:24 AM

I've just made that function public, so should appear in the source shortly. But I'm thinking Soma's jQuery solution seems like a pretty great one.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users