ZF-9350: Zend_Form Several Fixes Container - elementsBelongTo, Translator

Description

Reorganizing and cleaning SubTasks now.

  1. ZF-9348 Cleaned, with Unit Test, correctness Credo 100%
  2. ZF-9551 New, with Unit Test, correctness Credo 100%
  3. ZF-9540 Converted to SubTask, clean Description, Unit Test
  4. ZF-9361 Cleaned, with Unit Test, correctness Credo 100%
  5. ZF-9407 Cleaned, with Unit Test, correctness Credo 100%

  6. ZF-9586 New, Credo 100%

  7. ZF-9467 Cleaned with Unit Test, Credo 100%
  8. ZF-9584 New, Credo 100%
  9. ZF-9593 New, Credo 100%

Comments

This is a Fix for the whole Zend_Form package.

To Matthew Weier O'Phinney @ ZF-6062

Overloading actually works with variables with numeric values, i have a deeply nested setup working with numerical form names.

Notice for XHTML: ID and NAME must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

Look here: [http://www.w3.org/TR/2000/REC-xml-20001006#id] [http://www.w3.org/TR/2000/REC-xml-20001006#NT-Name]

Cleaned the patch, found the truly bug within isValid() and isValidPartial() which causes loss of data with SubForms and ElementsBelongTo.


public function isValid|isValidPartial
{
...
// This handles BelongsTo and returns in all cases, even without
// belongsTo Array Notation the data for the current (Sub)Form
$data = $this->_dissolveArrayValue($data, this->getElementsBelongTo());
...
// Here is the bug which eats SubForm data when descending deeper
// into $data as this is already done by dissolveArrayValue and will
// be done in the next cycle as well
if (isset($data[$key])) {
  $valid = $form->isValid($data[$key]) && $valid;
}
...
}

This is a bad idea: ??Invalid name provided; must be unique per (Sub)Form??

Example:



    Old price:
    


    New price:
    

Or


Kai Uwe the current implementation as found in the source of Zend Framework 1.10.2 simply overwrites your equal named submit buttons without notice.

you do

$form = new Zend_Form(); $form->addElement('submit','Submit',array('options'=>array('value'=>'red'))); $form->addElement('submit','Submit',array('options'=>array('value'=>'green'))); $form->render();

As result you will get a value="green" submit button, but no red one.

And if its not the correct syntax - hey, it's just an example.

Hi Christian, I know the bug in the current version, but your patch also doesn't solve the problem. Another idea: I think the Zend_Form class is not the right place. This part is better for decorators (Callback, ViewHelper, ViewScript) and/or the view.

Hi Christian. How can I apply this new fix?

Hey Sergio on linux console this is done with the patch command. But please be aware that this issue is not even commented yet by core developers.

Refactoring patches and Structure of issue.

Added a patch so changing Type.

That was the wrong issue ;P

Changing Priority since the 'loss of data Issues' are resolved.