本文整理汇总了PHP中BaseForm::bind方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseForm::bind方法的具体用法?PHP BaseForm::bind怎么用?PHP BaseForm::bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseForm
的用法示例。
在下文中一共展示了BaseForm::bind方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bind
/**
* Rewrite bind event to overload
* @param array $data
* @param $entity
* @param null $whitelist
*/
public function bind(array $data, $entity, $whitelist = null)
{
//Validator for email address format
if (!empty($data['email'])) {
$this->get('email')->addValidator(new EmailValidator(['message' => '<strong>Email</strong> address is invalid.']));
$this->get('email')->addValidator(new Uniqueness(['collection' => 'User', 'field' => 'email', 'message' => '<strong>Email</strong> is already used by another account.']));
}
parent::bind($data, $entity, $whitelist);
}
示例2: processForm
private function processForm($params, BaseForm $form)
{
$form->bind($params);
if ($form->isValid()) {
$form->save();
return true;
}
return false;
}
示例3: bind
/**
* Binds the form with input values, adding recaptcha values
* @param array $taintedValues An array of input values
* @param array $taintedFiles An array of uploaded files (in the $_FILES or $_GET format)
*/
public function bind(array $taintedValues = null, array $taintedFiles = null)
{
if (sfConfig::get('app_recaptcha_active', false)) {
$request = sfContext::getInstance()->getRequest();
$taintedValues['challenge'] = $request->getParameter('recaptcha_challenge_field');
$taintedValues['response'] = $request->getParameter('recaptcha_response_field');
}
parent::bind($taintedValues, $taintedFiles);
}
示例4: processForm
protected function processForm(sfWebRequest $request, BaseForm $form)
{
$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
if ($form->isValid()) {
$schedule = $form->save();
$this->getUser()->setFlash('notice', $form->isNew() ? 'The schedule has added' : 'The schedule has updated');
$results = explode('-', $schedule->start_date);
$this->redirect(sprintf('@calendar_year_month?year=%d&month=%d', $results[0], $results[1]));
}
}
示例5: bind
public function bind(array $data, $entity, $whitelist = null)
{
if (!isset($data['status'])) {
$data['status'] = 0;
}
//Validator for date and time
if ($data['type'] == 'once') {
$this->get('datetime')->addValidator(new DateTimeValidator());
}
//validator for job_sel
if ($data['type'] == 'repetitiv') {
$this->get('job_sel')->addValidator(new PresenceOf(['message' => 'Choose a period to setup a cron.']));
}
//Validator for cron custom definition
if ($data['job_sel'] == 'custom') {
$this->get('job')->addValidator(new PresenceOf(array('message' => 'The cron custom def. is required.')));
}
parent::bind($data, $entity, $whitelist);
}
示例6: bind
public function bind(array $taintedValues = null, array $taintedFiles = null)
{
if (isset($taintedValues['newVal'])) {
foreach ($taintedValues['newVal'] as $key => $newVal) {
if (!isset($this['newVal'][$key])) {
$taintedValues['newVal'][$key]['referenced_relation'] = $this->options['table'];
$taintedValues['newVal'][$key]['record_id'] = $this->options['id'];
$this->addValue($key);
}
}
}
if (isset($taintedValues['VernacularNames'])) {
foreach ($taintedValues['VernacularNames'] as $key => $newVal) {
$taintedValues['VernacularNames'][$key]['referenced_relation'] = $this->options['table'];
$taintedValues['VernacularNames'][$key]['record_id'] = $this->options['id'];
}
}
parent::bind($taintedValues, $taintedFiles);
}
示例7: checkCSRFProtection
public function checkCSRFProtection()
{
$form = new BaseForm();
$form->bind($form->isCSRFProtected() ? array($form->getCSRFFieldName() => $this->getParameter($form->getCSRFFieldName())) : array());
if (!$form->isValid()) {
throw $form->getErrorSchema();
}
}
示例8: executeDeletePair
public function executeDeletePair(sfWebRequest $request)
{
$pair = MappingPairTable::getInstance()->find($request->getParameter('id'));
if (!$pair) {
return $this->notFound();
}
/* @var $pair MappingPair */
$form = new BaseForm();
$form->getWidgetSchema()->setNameFormat('delete_pair[%s]');
$form->bind($request->getPostParameter($form->getName()));
if ($form->isValid()) {
$id = $pair->getId();
$pair->delete();
return $this->ajax()->remove('#pair_' . $id)->remove('#pair_form_' . $id)->render();
} else {
return $this->ajax()->form($form)->render();
}
}
示例9: sfWidgetFormTextarea
$this->setWidget('body', new sfWidgetFormTextarea());
$this->setValidator('body', new sfValidatorString(array('min_length' => 12)));
}
}
$configuration = $configuration->getApplicationConfiguration('frontend', 'test', true, null, $configuration->getEventDispatcher());
sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir'));
$enhancer = new sfFormYamlEnhancerTest($configuration->getConfigCache());
// ->enhance()
$t->diag('->enhance()');
$form = new CommentForm();
$form->bind(array('body' => '+1'));
$enhancer->enhance($form);
$t->like($form['body']->renderLabel(), '/Please enter your comment/', '->enhance() enhances labels');
$t->like($form['body']->render(), '/class="comment"/', '->enhance() enhances widgets');
$t->like($form['body']->renderError(), '/You haven\'t written enough/', '->enhance() enhances error messages');
$form = new CommentForm();
$form->bind();
$enhancer->enhance($form);
$t->like($form['body']->renderError(), '/A base required message/', '->enhance() considers inheritance');
class SpecialCommentForm extends CommentForm
{
}
$form = new SpecialCommentForm();
$form->bind();
$enhancer->enhance($form);
$t->like($form['body']->renderLabel(), '/Please enter your comment/', '->enhance() applies parent config');
$form = new BaseForm();
$form->embedForm('comment', new CommentForm());
$form->bind();
$enhancer->enhance($form);
$t->like($form['comment']['body']->renderLabel(), '/Please enter your comment/', '->enhance() enhances embedded forms');
示例10: processForm
private function processForm(BaseForm $form, sfWebRequest $request, $type = null)
{
$name = $form->getName();
$form->bind($request->getParameter($name), $request->getFiles($name));
if ($this->setFlashMessageByType($form->isValid(), $type)) {
$form->save();
}
$this->redirect('@opCalendarPlugin');
}