Pagemaster input template + manual HTML  Bottom

Go to page 1 - 2 [+1]:

  • Hi,

    I'm having a complex pagemaster publication for which I built a custom input template. For the most part I'm using standard pagemaster syntax, but for a few items (a select dropdown + a collection of radio buttons) I just manually wrote the HTML into the template. Everything displays fine but the values from the select dropdown and the radio buttons aren't being saved.

    What kind of magic do I have to perform in order to properly integrate standard HTML input elements into what is otherwise a pnForm form?

    Greetings/Thanks
    Robert
  • You cannot get values from the standard pnForm method. For instance, when you are handling a form in pnForm code, you would normally call it like this...

    Code

    $data = $render->pnFormGetValues();


    This will get you all the pnForm defined values. They come back to you in a array that is held in the $data variable. If you add your own values, you have to add an extra call to collect those. For exam, my form had an extra field called id. To grab that you do the classic Zikula call...

    Code

    $data['id'] = FormUtil::getPassedValue('id');


    Note that I added this right to the $data array to keep all my values in one place.
  • OK, thanks, that is clear. In a pagemaster context where, do you know where I would add this call?

    Greetings/Thanks
    Robert
  • After starting to look through the code, it seems there should be a method of registering an HTML input element as a pnForm element. That way all of this could be done at the template level.

    Something like this:

    Code

    <input type="text" name="blah" ....>
    <!--[pnform_registerinputfield ...]-->


    Does something like this exist?

    Greetings/Thanks
    Robert
  • I don't use any of the stuff you are discussing but what about naming the fields like:

    Code

    <input type='text' name='data[]'>

    then the data would be passed with the other vars? just a shot in the dark here.
  • I tried to figure out what is going on. A field generated through standard pagemaster/pnForm call (for the pagemaster field "name") looks like this:

    Code

    <div class="z-formrow">
      <label for="name">Name<span class="z-mandatorysym">*</span></label>
      <input type="text" id="name" name="name" class="text" value="Donald Duck"/>
    </div>


    So I tried the following (for the pagemaster field "phone1_type")

    Code

    <div class="z-formrow">
      <label for="phone1_type">Phone 1 Type<span class="z-mandatorysym">*</span></label>
      <select name="phone1_type" id="phone1_type">
        <option value="">Choose One</option>
        <option value="work">Work</option>
        <option value="home">Home</option>
        <option value="cell">Cell</option>
        <option value="fax">Fax</option>
      </select>
    </div>


    The HTML is correct, but pnForm does not pick_up/store the value. So something else is missing. I'm guessing that what's missing is a call which tells pnForm that the field "phone1_type" should be fetched/processed/saved. The bad thing is that I have no idea how to do this.

    Any ideas?

    Greetings/Thanks
    Robert
  • The first thing that crosses my mind is that you need some sort of field in the PageMaster pubtype to store the data. This could simply be a string field in the pubtype. Then you would just build the form elements manually with names and IDs that match the field names created in PM.

    Is that clear as mud? icon_wink

    --
    Harness Technology
  • Well
    Note that the PageMaster code is made generic to administer "unlimited" pubtypes (forms) with their values, considering the registered fields and from there, build the templates and the DB tables.

    Personally, I haven't played with pnform stuff directly on PageMaster forms, but I guess there won't be too much trouble, because PageMaster plugins are already "childs" of the core framework. And ATM, that's required to manipulate radio buttons, because there's no PageMaster plugin for that.

    But about the dropdown, you can create a list, with your options listed as a category tree, and configuring the plugin with the root CatID.

    I will work on a example in the next few hours.

    --
    - Mateo T. -
    Mis principios... son mis fines
  • Quote

    The first thing that crosses my mind is that you need some sort of field in the PageMaster pubtype to store the data.

    Of course, that was the first thing I did ...

    Quote

    This could simply be a string field in the pubtype. Then you would just build the form elements manually with names and IDs that match the field names created in PM

    That's what I did but that doesn't work ... therefore this thread ...

    Greetings/Thanks
    R
  • Quote

    Personally, I haven't played with pnform stuff directly on PageMaster forms, but I guess there won't be too much trouble, because PageMaster plugins are already "childs" of the core framework.

    Yes, but that *requires* you to build your forms using pnForm. For flexibilities sake, I really think there should be a way of getting forms to work using plain HTML (with possibly some pnRender plugin calls added).

    Greetings
    R
  • Quote

    Yes, but that *requires* you to build your forms using pnForm. For flexibilities sake, I really think there should be a way of getting forms to work using plain HTML (with possibly some pnRender plugin calls added).
    Well
    even when I don't know all the power behind the Form Framework, I see its advantages with the basic stuff.

    Flexibility here can mean to copy+paste HTML and make it work with the framework, but the flexibility that PageMaster wants is web and workflow management.

    So, the dropdown can be a List as I said, and you can register the radio list as a List field too, and use something like this in the template:

    Code

    <div class="z-formrow">
        {formlabel __text='Category'}
        <div class="z-formnote">
            {formradiobutton id='category_39' dataField='category' value='39'} {formlabel for='category_39' __text='Science and technology'}
            {formradiobutton id='category_40' dataField='category' value='40'} {formlabel for='category_40' __text='Sport and activities'}
            {formradiobutton id='category_38' dataField='category' value='38'} {formlabel for='category_38' __text='Travel and culture'}
            {formradiobutton id='category_36' dataField='category' value='36'} {formlabel for='category_36' __text='Writing and thinking'}
            {formradiobutton id='category_34' dataField='category' value='34'} {formlabel for='category_34' __text='Music and audio'}
            {formradiobutton id='category_37' dataField='category' value='37'} {formlabel for='category_37' __text='Communications and media'}
            {formradiobutton id='category_35' dataField='category' value='35'} {formlabel for='category_35' __text='Art and photography'}
            {formradiobutton id='category_33' dataField='category' value='33'} {formlabel for='category_33' __text='Blogging'}
            {formradiobutton id='category_41' dataField='category' value='41'} {formlabel for='category_41' __text='Business and work'}
            {formradiobutton id='category_42' dataField='category' value='42'} {formlabel for='category_42' __text='Activism and action'}
        </div>
    </div>


    A new advantage has come to my mind:
    The List plugin, using a category tree, saves time in the display template, or how flexible it is with hardcoded HTML?

    Greetz

    --
    - Mateo T. -
    Mis principios... son mis fines
  • Also, with my little knowledge of pnForm, I guess it's not possible to "merge" plain HTML with its dynamics. Or if possible, you may need to code a Fake pnForm Plugin class anyways, because you need to register a Plugin Class to get the value in the Form Handler.

    pnForm uses Smarty and custom classes to register the values present on the form, validate them, etc. In the other hand, the PageMaster's Form Handler is generic for all the pubtypes, and to hack it to parse the value with FormUtil::getPassedValue for tid==X is kinda ugly.

    So, IMHO, it's cheaper to move the HTML to Categories / RadioInput code.

    --
    - Mateo T. -
    Mis principios... son mis fines
  • OK, I've recoded my form using categories and the pagemaster list type and even though it took a while to enter it all into the category manager, it now works.

    Moral of the story: use the architecture as it was intended!

    Greetings/Thanks
    R
  • Is there a ticket on category tree import/export already ? Otherwise that makes sense for these kind of category lists for dropdown fields icon_biggrin

    --
    campertoday.nl, Module development, Dutch Zikula Community
  • Yes, there is a ticket on import/export of category tree stuff. And it's been set, as I recall to "Won't Fix" due to a 3rd party module that should be able to handle it.

    --
    Home Page | Find on Facebook | Follow on Twitter

Go to page 1 - 2 [+1]:

  • 0 users

This list is based on users active over the last 60 minutes.