Note that there are some explanatory texts on larger screens.

plurals
  1. POChanging the validator of an embedded form field
    primarykey
    data
    text
    <p>I have this schema:</p> <pre><code>propel: autor: id: ~ nombre: { type: varchar, size: 255, required: true } libro: id: ~ autor_id: { type: integer, size: 11, foreignTable: autor, foreignReference: id} titulo: { type: varchar, size: 255 } paginas: { type: varchar, size: 255, required: true } </code></pre> <p>and this form class:</p> <pre><code>class AutorForm extends BaseAutorForm { public function configure() { $this-&gt;embedRelation('Libro'); } public function foo() { $this-&gt;validatorSchema['Libro']['newLibro1']['paginas'] = new sfValidatorPass(); return $this; } } </code></pre> <p>I'm calling foo() after the bind() (inside processForm()).</p> <p>After submiting the Auto-Libro form, if I don't insert anything in the field 'paginas' of the first embedded form (Libro), it shows "Required".</p> <p>But.. why if paginas has a validator-pass?</p> <p><strong>EDIT</strong>: after matt's answer, this is my code:</p> <pre><code>var_dump($this-&gt;embeddedForms['Libro']-&gt;validatorSchema['newLibro1']['paginas']); $this-&gt;embeddedForms['Libro']-&gt;validatorSchema['newLibro1']['paginas'] = new sfValidatorPass(array('required' =&gt; false)); var_dump($this-&gt;embeddedForms['Libro']-&gt;validatorSchema['newLibro1']['paginas']); </code></pre> <p>It prints this:</p> <pre><code>object(sfValidatorString)[152] protected 'requiredOptions' =&gt; array empty protected 'defaultMessages' =&gt; array 'required' =&gt; string 'Required.' (length=9) 'invalid' =&gt; string 'Invalid.' (length=8) 'max_length' =&gt; string '"%value%" is too long (%max_length% characters max).' (length=52) 'min_length' =&gt; string '"%value%" is too short (%min_length% characters min).' (length=53) protected 'defaultOptions' =&gt; array 'required' =&gt; boolean true 'trim' =&gt; boolean false 'empty_value' =&gt; string '' (length=0) 'max_length' =&gt; null 'min_length' =&gt; null protected 'messages' =&gt; array 'required' =&gt; string 'Required.' (length=9) 'invalid' =&gt; string 'Invalid.' (length=8) 'max_length' =&gt; string '"%value%" is too long (%max_length% characters max).' (length=52) 'min_length' =&gt; string '"%value%" is too short (%min_length% characters min).' (length=53) protected 'options' =&gt; array 'required' =&gt; boolean true 'trim' =&gt; boolean false 'empty_value' =&gt; string '' (length=0) 'max_length' =&gt; int 255 'min_length' =&gt; null object(sfValidatorPass)[196] protected 'requiredOptions' =&gt; array empty protected 'defaultMessages' =&gt; array 'required' =&gt; string 'Required.' (length=9) 'invalid' =&gt; string 'Invalid.' (length=8) protected 'defaultOptions' =&gt; array 'required' =&gt; boolean true 'trim' =&gt; boolean false 'empty_value' =&gt; null protected 'messages' =&gt; array 'required' =&gt; string 'Required.' (length=9) 'invalid' =&gt; string 'Invalid.' (length=8) protected 'options' =&gt; array 'required' =&gt; boolean false &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; FALSE &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; 'trim' =&gt; boolean false 'empty_value' =&gt; null </code></pre> <p>The problem is still the same: when i try to submit the form, the field 'paginas' is still required. Why?</p> <p>sf 1.4/propel 1.6</p> <p>Javi </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload