$4
Trouble with formular
i'm having a problem with getting data from a formular. But before i start explaining the issue, here are some information:
schema.yml
Blaetter:
actAs:
Timestampable: ~
columns:
bezeichnung: { type: string(50), notnull: true }
abschnitt_id: { type: integer, notnull: true }
blatt_nr: { type: integer, notnull: true}
typ: { type: string(1), notnull: true }
termin: { type: timestamp(25), notnull: false }
created_by: { type: integer, notnull: true }
updated_by: { type: integer, notnull: true }
relations:
Abschnitte: { onDelete: RESTRICT, local: abschnitt_id, foreign: id}
AktuellesBlatt:
columns:
id: { type: integer, primary: true, notnull: true}
relations:
Blaetter: { onDelete: SET NULL, local: id, foreign: id }
As you can see on the attached image, i want to have radio-buttons for the type "Übungsblatt". After choosing one and pushing the submit-Button i get the following Error
500 | Internal Server Error | sfValidatorErrorSchema
bezeichnung [Required.] abschnitt_id [Required.] blatt_nr [Required.] typ [Required.] _csrf_token [Required.]
stack trace
at ()
in SF_ROOT_DIR/lib/vendor/symfony/lib/validator/sfValidatorSchema.class.php line 110 ...
$clean = array();
$unused = array_keys($this->fields);
$errorSchema = new sfValidatorErrorSchema($this);
// check that post_max_size has not been reached
if (isset($_SERVER['CONTENT_LENGTH']) && (int) $_SERVER['CONTENT_LENGTH'] > $this->getBytes(ini....)
I tried creating the formular the old-fashioned way, because i only need the radio-buttons for getting one Id (indexSuccess.php):
<h1>Blaetters List</h1>
<form action="<? url_for('blaetter/index'); ?>" method="post" >
<table border="1">
<thead>
<tr>
<th>Id</th>
<th>Aktuell</th>
<th>Bezeichnung</th>
<th>Abschnitt</th>
<th>Blatt nr</th>
<th>Typ</th>
<th>Termin</th>
<th>Operation</th>
<th>Created at</th>
<th>Updated at</th>
<th>Created by</th>
<th>Updated by</th>
</tr>
</thead>
<tbody>
<?php foreach ($blaetters as $blaetter): ?>
<tr>
<td><?php echo $abschnitte[$blaetter->getAbschnittId()].".".$blaetter->getBlattNr() ?></td>
<td>
<?php if ($blaetter->getTyp()==sfConfig::get('app_blaetter_uebung')):?>
<input type="radio" name="aktBlatt" value="<?php echo $blaetter->getId() ?>" />
<?php endif;?>
</td>
<td><?php echo $blaetter->getBezeichnung() ?></td>
<td><?php echo $abschnitte[$blaetter->getAbschnittId()] ?></td>
<td><?php echo $blaetter->getBlattNr() ?></td>
<td><?php echo sfConfig::get('app_blaetter_'.$blaetter->getTyp()) ?></td>
<td>
<?php $termin=$blaetter->getTermin();
if($termin!=str_replace(";",":",sfConfig::get('app_datum_defaultDatum'))&&($termin!='')&&($blaetter->getTyp()==sfConfig::get('app_blaetter_uebung'))){
echo DateTime::createFromFormat(sfConfig::get('app_datum_mysqlDatum'),$blaetter->getTermin())->format(sfConfig::get('app_datum_datumsFormat'));
}else{ echo sfConfig::get("app_datum_noDatum"); }
?>
</td>
<td>
<?php echo link_to1('Ändern','blaetter/edit?id='.$blaetter->getId())?> |
<?php echo link_to1('Löschen','blaetter/del?id='.$blaetter->getId())?> | Benotung | Einzelergebnisse drucken
</td>
<td>
<?php if($blaetter->getCreatedAt()!=str_replace(";",":",sfConfig::get('app_datum_defaultDatum'))){
echo DateTime::createFromFormat(sfConfig::get('app_datum_mysqlDatum'),$blaetter->getCreatedAt())->format(sfConfig::get('app_datum_datumsFormat'));
}else{ echo sfConfig::get("app_datum_noDatum"); }
?>
</td>
<td>
<?php if($blaetter->getUpdatedAt()!=str_replace(";",":",sfConfig::get('app_datum_defaultDatum'))){
echo DateTime::createFromFormat(sfConfig::get('app_datum_mysqlDatum'),$blaetter->getUpdatedAt())->format(sfConfig::get('app_datum_datumsFormat'));
}else{ echo sfConfig::get("app_datum_noDatum");}
?>
</td>
<td><?php echo $dozenten[$blaetter->getCreatedBy()] ?></td>
<td><?php echo $dozenten[$blaetter->getUpdatedBy()] ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<!--
<input type="hidden" name="bezeichnung" value="" />
<input type="hidden" name="abschnitt_id" value="" />
<input type="hidden" name="blatt_nr" value="" />
<input type="hidden" name="typ" value="" />
-->
<input type="submit" value=" Absenden ">
</form>As you can see I already tried to give the "required-values" through hidden fields (uncommented), but that idea doesn't brought me any further.
I have searched for a function to disable the sfValidator only for this formular, but haven't found anything.
So do you know, what is wrong with my code?
Martin Baudrechsel | 05/18/10 at 1:34pm
| Edit
(1) Possible Answers Submitted...
-

Last edited:
05/18/10
2:32pmWojciech Sznapka says:you can set in form class in configure method:
$this->validatorSchema['FIELD_NAME']->setOption('required', false);
or set sfValidatorPass for non-validating vields:
$this->validatorSchema['FIELD_NAME'] = new sfValidatorPass()
or simply you can unset unnecessary fields this way (still in form class configure method):
unset($this['FIELD_NAME']);
Previous versions of this answer: 05/18/10 at 1:45pm
- 05/18/10 1:47pm
Martin Baudrechsel says:tried both:
$this->validatorSchema['FIELD_NAME']->setOption('required', false);
class AktuellesBlattDefinitionForm extends sfForm{
public function configure(){
$this->validatorSchema['bezeichnung']->setOption('required', false);
$this->validatorSchema['abschnitt_id']->setOption('required', false);
$this->validatorSchema['blatt_nr']->setOption('required', false);
$this->validatorSchema['typ']->setOption('required', false);
}
}
Result:
Fatal error: Call to a member function setOption() on a non-object in /Applications/XAMPP/xamppfiles/htdocs/bachelor/lib/form/doctrine/AktuellesBlattDefinitionForm.class.php on line 29
The Other Solution:
in configure():
$this->validatorSchema['bezeichnung'] = new sfValidatorPass();
$this->validatorSchema['abschnitt_id'] = new sfValidatorPass();
$this->validatorSchema['blatt_nr'] = new sfValidatorPass();
$this->validatorSchema['typ'] = new sfValidatorPass();
Result:
Again the Error mentioned above (sfValidatorErrorSchema) - 05/18/10 1:49pm
Martin Baudrechsel says:unsetting gives me again the sfValidatorErrorSchema-Error
- 05/18/10 1:52pm
Wojciech Sznapka says:please provide code for blaetter/index action
- 05/18/10 1:53pm
Martin Baudrechsel says:maybe you need more information:
myAction:
class blaetterActions extends sfActions
{
public function executeIndex(sfWebRequest $request)
{
$this->form=new AktuellesBlattDefinitionForm();
$blaetters = Doctrine::getTable('Blaetter')
->createQuery('a')
->orderBy('typ,abschnitt_id,blatt_nr')
->execute();
$this->blaetters=$blaetters;
$this->abschnitte=$this->getAbschnitte();
$this->dozenten=DozentenTable::getDozentNameByFk();
/* $this->forward404Unless($request->isMethod(sfRequest::POST));
$this->forward404Unless(($blatt = Doctrine::getTable('blaetter')->findOneBy('id',$request->getParameter('id'))), sprintf('Objekt existiert nicht (%s).', $request->getParameter('id')));*/
}
}
}
$this->form= new AktuellesBlattDefinitionForm(); I am just doing to create an instance of the class and activating the things you said:
AktuellesBlattDefinitionForm:
class AktuellesBlattDefinitionForm extends sfForm{
public function configure(){
/*$this->validatorSchema['bezeichnung']->setOption('required', false);
$this->validatorSchema['abschnitt_id']->setOption('required', false);
$this->validatorSchema['blatt_nr']->setOption('required', false);
$this->validatorSchema['typ']->setOption('required', false);*/
/*$this->validatorSchema['bezeichnung'] = new sfValidatorPass();
$this->validatorSchema['abschnitt_id'] = new sfValidatorPass();
$this->validatorSchema['blatt_nr'] = new sfValidatorPass();
$this->validatorSchema['typ'] = new sfValidatorPass();*/
//$this->widgetSchema->setNameFormat('aktuellesBlatt[%s]');
unset($this['bezeichnung'],$this['abschnitt_id'],$this['blatt_nr'],$this['typ']);
}
}
- 05/18/10 1:58pm
Wojciech Sznapka says:how can it throw you any error while you aren't doing anything but displaying data in blaetter/index ? Where are you handling form?
- 05/18/10 2:05pm
Martin Baudrechsel says:that's why I'm really confused...
i'm displaying the data, as you can see above...
the error occourse after submitting the form
<form action="<? url_for('blaetter/index'); ?>" method="post" >
[---displaying data-----]
<input type="radio" name="aktBlatt" value="<?php echo $blaetter->getId() ?>" />
[---displaying data-----]
<input type="submit" value=" Absenden ">
</form> - 05/18/10 2:07pm
Wojciech Sznapka says:haven't you modified routing? Maybe the form directs somewhere else...
- 05/18/10 2:15pm
Martin Baudrechsel says:that sucks... you are right... i already tried it before, but i did something wrong at this try...
Thank you so much! - 05/18/10 2:19pm
Wojciech Sznapka says:so you messed up routing? :-)
- 05/18/10 2:22pm
Martin Baudrechsel says:yeah, i still have problems with this. the jobeet tutorial doesn't really helped me.
I choose you as winner, just want to make sure if that really is the reason.
- 05/18/10 1:47pm
This question has expired.
Current status of this question: Completed





