-- Juan Felipe Alvarez Saldarriaga <[EMAIL PROTECTED]> wrote
(on Monday, 20 October 2008, 12:59 PM +0000):
> Why isn't valid ? I mean, now I know how to do it, but, why is not a
> valid php name ?
We require valid PHP names for elements to ensure that overloading and
other functionality can work correctly. PHP element names must begin
with an underscore or alphabetic character; $1 is an invalid variable
name.
> ----- Original Message -----
> From: "Paweł Chuchmała" <[EMAIL PROTECTED]>
> To: "Juan Felipe Alvarez Saldarriaga" <[EMAIL PROTECTED]>
> Sent: Sunday, October 19, 2008 12:26:23 PM GMT -05:00 Columbia
> Subject: Re: [fw-general] Zend_Form name of the elements issue
>
>
> Form element name must be valid php name.
>
>
> On Sun, Oct 19, 2008 at 18:21, Juan Felipe Alvarez Saldarriaga < [EMAIL
> PROTECTED] > wrote:
>
>
> Hey!
>
> I'm trying to create a Zend_Form with all elements part of array, meaning:
>
> <input type="text" name="form[1]" value="" />
> <input type="text" name="form[2]" value="" />
> <input type="text" name="form[3]" value="" />
>
> ...
>
> I'm doing this:
>
> // Load model.
> $model = new Model();
>
> // Get an instance of Zend_Form.
> $form = new Zend_Form();
>
> // Get form elements from my db.
> $elements = $model->getFormElements();
>
> // Loop trough every form db element, create the element and add it to the
> Zend_Form object.
> foreach ( $elements AS $elementId => $elementData )
> {
> // Create an instance of Zend_Form_Element_* and put a name like an array
> (array[$index]).
> $formElement = new $elementData["class"]( "form[{$elementId}]" );
>
> $form->addElement( $formElement );
> }
>
> The problem is, when I saw the form html code, I got this:
>
> <input type="text" value="" id="form42" name="form42"/>
>
> The "[" and "]" chars are stripped, why ? how can I create a form that all
> elements belog to an array ?
>
> Thx for any help.
>
>
>
> --
> Paweł Chuchmała
> pawel.chuchmala at gmail dot com
>
--
Matthew Weier O'Phinney
Software Architect | [EMAIL PROTECTED]
Zend Framework | http://framework.zend.com/