Saturday, November 22, 2014

Custom name for dropdown generated by formhelper

I'm building a CMS system with a module called "CmsPage' (list, add, edit, sort delete). Every cms page links via a <select></select> to another cms page and it tells which record the parent cms page is.
The select dropdown holds all the values from the table "cms_pages". 

Here's my add.php with the form helper that shows a list with cms pages:

<?php

echo $this->Form->create('CmsPage', array(
    'type' => 'file',
    'novalidate' => true,
    'inputDefaults' => array(
        'label' => true,
        'div' => 'form-group',
        'class' => 'form-control'
    ),
    'role' => 'form'
));

echo $this->Form->inputs(array(
    'legend' => false,
    'name' => array(
        'label' => 'Naam'
    ),
    'cmsPages' => array(
        'label' => 'Parent CMS page'
    ),
    'plugin' => array(
        'label' => 'Plugin'
    ),
    'controller' => array(
        'label' => 'Controller'
    ),
    'action' => array(
        'label' => 'Action'
    )
));

echo $this->Form->end('Save');

?>

Naming conventions require that the name of the <select> should be"cmsPages". But hey, I want to call it "parentNode"!
But when I do so, the dropdown changes in a simple textfield instead of the <select> dropdown.

Is to rename the red marked word above to "parentNode"? If yes... How? ;)

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: