Jump to content

FormTemplateProcessor with Page Fieldtype


vitor
 Share

Recommended Posts

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

post-389-0-98959400-1332350059_thumb.png

Link to comment
Share on other sites

Ok,

I've managed to resolve this using the Module Fieldtype Select (AKA Drop Down) here: this way I just created a new Select field and add the required options.

Thanks guys for the Module.

Best

Link to comment
Share on other sites

  • 4 months later...

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!!!

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

@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.

Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...