本文整理汇总了PHP中sfForm::getWidgetSchema方法的典型用法代码示例。如果您正苦于以下问题:PHP sfForm::getWidgetSchema方法的具体用法?PHP sfForm::getWidgetSchema怎么用?PHP sfForm::getWidgetSchema使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfForm
的用法示例。
在下文中一共展示了sfForm::getWidgetSchema方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup
public static function setup(sfForm $form)
{
$formatter = new pmWidgetFormSchemaFormatterTable($form);
$form->getWidgetSchema()->addFormFormatter("pm_table", $formatter);
$form->getWidgetSchema()->setFormFormatterName("pm_table");
$form->unsetFields();
// auto configure widgets
pmWidgetFactory::replaceWidgets($form);
// auto configure validators
pmValidatorFactory::replaceValidators($form);
$form->configureWidgets();
$form->configureValidators();
if ($form instanceof pmFormPropel) {
$sf_user = sfContext::getInstance()->getUser();
if (method_exists($sf_user, "getGuardUser")) {
$user_id = $sf_user->getGuardUser()->getId();
if (array_key_exists("created_by", $form->getWidgetSchema()->getFields()) && $form->getObject()->isNew()) {
$form->getObject()->setCreatedBy($user_id);
}
if (array_key_exists("updated_by", $form->getWidgetSchema()->getFields())) {
$form->getObject()->setUpdatedBy($user_id);
}
}
}
}
示例2: embedWidgetIntoForm
/**
* Embeds this widget into the form. Sets label and validator for this widget.
* @param sfForm $form
*/
public function embedWidgetIntoForm(sfForm &$form)
{
$activeProjectFound = false;
$userRoleManager = sfContext::getInstance()->getUserRoleManager();
$projectList = $userRoleManager->getAccessibleEntities('Project');
foreach ($projectList as $project) {
if ($project->getIsDeleted() != 0) {
$activeProjectFound = true;
break;
}
}
$requiredMess = __('Select a project');
if (!$activeProjectFound) {
$requiredMess = __("No Projects Defined");
}
$widgetSchema = $form->getWidgetSchema();
$widgetSchema[$this->attributes['id']] = $this;
$label = __(ucwords(str_replace("_", " ", $this->attributes['id'])));
$validator = new sfValidatorString();
if ($this->attributes['required'] == "true") {
$label .= "<span class='required'> * </span>";
$validator = new sfValidatorString(array('required' => true), array('required' => $requiredMess));
}
$widgetSchema[$this->attributes['id']]->setLabel($label);
$form->setValidator($this->attributes['id'], $validator);
}
示例3: embedWidgetIntoForm
/**
* Embeds this widget into the form. Sets label and validator for this widget.
* @param sfForm $form
*/
public function embedWidgetIntoForm(sfForm &$form)
{
$widgetSchema = $form->getWidgetSchema();
// $validatorSchema = $form->getValidatorSchema();
$widgetSchema[$this->attributes['id']] = $this;
// $widgetSchema[$this->attributes['id']]->setLabel(ucwords(str_replace("_", " ", $this->attributes['id'])));
}
示例4: embedWidgetIntoForm
/**
* Embeds this widget into the form.
* @param sfForm $form
*/
public function embedWidgetIntoForm(sfForm &$form)
{
$widgetSchema = $form->getWidgetSchema();
$widgetSchema[$this->attributes['id']] = $this;
$label = ucwords(str_replace("_", " ", $this->attributes['id']));
$widgetSchema[$this->attributes['id']]->setLabel($label);
$form->setValidator($this->attributes['id'], new sfValidatorPass());
}
示例5: embedWidgetIntoForm
/**
* Embeds this widget into the form. Sets label and validator for this widget.
* @param sfForm $form
*/
public function embedWidgetIntoForm(sfForm &$form)
{
$widgetSchema = $form->getWidgetSchema();
$validatorSchema = $form->getValidatorSchema();
$widgetSchema[$this->attributes['id']] = $this;
$widgetSchema[$this->attributes['id']]->setLabel(__(ucwords(str_replace("_", " ", $this->attributes['id']))));
$validatorSchema[$this->attributes['id']] = new ohrmValidatorDateRange(array(), array("invalid" => "Insert a correct date"));
}
示例6: embedWidgetIntoForm
/**
* Embeds this widget into the form. Sets label and validator for this widget.
* @param sfForm $form
*/
public function embedWidgetIntoForm(sfForm &$form)
{
$widgetSchema = $form->getWidgetSchema();
$validatorSchema = $form->getValidatorSchema();
$widgetSchema[$this->attributes['id']] = $this;
$widgetSchema[$this->attributes['id']]->setLabel(ucwords(str_replace("_", " ", $this->attributes['id'])));
$required = $requiredMessage = __(ValidationMessages::REQUIRED);
$validatorSchema[$this->attributes['id']] = new ohrmValidatorConditionalFilter(array(), array('required' => $requiredMessage));
}
示例7: executeAjaxAddInvoiceItem
/**
* AJAX action to add new invoice items
* @param sfWebRequest $request
* @return unknown_type
*/
public function executeAjaxAddInvoiceItem(sfWebRequest $request)
{
$index = 'new_item_invoice_' . time();
$item = new Item();
$item->common_id = $request->getParameter('invoice_id');
$form = new sfForm();
$form->getWidgetSchema()->setNameFormat('invoice[%s]');
$form->embedForm('Items', new FormsContainer(array($index => new ItemForm($item)), 'ItemForm'));
$params = array('invoiceItemForm' => $form['Items'][$index], 'item' => $item, 'isNew' => true, 'rowId' => $index);
return $this->renderPartial('invoiceRow', $params);
}
示例8: embedWidgetIntoForm
/**
* Embeds this widget into the form. Sets label and validator for this widget.
* @param sfForm $form
*/
public function embedWidgetIntoForm(sfForm &$form)
{
$widgetSchema = $form->getWidgetSchema();
$widgetSchema[$this->attributes['id']] = $this;
$label = ucwords(str_replace("_", " ", $this->attributes['id']));
$validator = new sfValidatorChoice(array('choices' => array_keys($this->subDivisionList)));
if ($this->attributes['required'] == "true") {
$label .= "<span class='required'> * </span>";
}
$widgetSchema[$this->attributes['id']]->setLabel($label);
$form->setValidator($this->attributes['id'], $validator);
}
示例9: embedWidgetIntoForm
public function embedWidgetIntoForm(sfForm $form)
{
$widgetSchema = $form->getWidgetSchema();
$validatorSchema = $form->getValidatorSchema();
$widgetSchema['from_date'] = new ohrmWidgetDatePicker(array(), array('id' => 'from_date'));
$widgetSchema['from_date']->setLabel("From ");
$form->setValidator('from_date', new sfValidatorDate());
$widgetSchema['to_date'] = new ohrmWidgetDatePicker(array(), array('id' => 'to_date'));
$widgetSchema['to_date']->setLabel("To ");
$form->setValidator('to_date', new sfValidatorDate());
$validatorSchema->setPostValidator(new sfValidatorSchemaCompare('from_date', sfValidatorSchemaCompare::LESS_THAN_EQUAL, 'to_date', array('throw_global_error' => true), array('invalid' => 'The from date ("%left_field%") must be before the to date ("%right_field%")')));
return $form;
}
示例10: embedWidgetIntoForm
/**
* Embeds this widget into the form. Sets label and validator for this widget.
* @param sfForm $form
*/
public function embedWidgetIntoForm(sfForm &$form)
{
$widgetSchema = $form->getWidgetSchema();
$widgetSchema[$this->attributes['id']] = $this;
$label = ucwords(str_replace("_", " ", $this->attributes['id']));
$validator = new sfValidatorString();
if ($this->attributes['required'] == "true") {
$label .= "<span class='required'> * </span>";
$validator = new sfValidatorString(array('required' => true), array('required' => 'No employees added to the system'));
}
$widgetSchema[$this->attributes['id']]->setLabel($label);
$form->setValidator($this->attributes['id'], $validator);
}
示例11: embedWidgetIntoForm
/**
* Embeds this widget into the form. Sets label and validator for this widget.
* @param sfForm $form
*/
public function embedWidgetIntoForm(sfForm &$form)
{
$widgetSchema = $form->getWidgetSchema();
$widgetSchema[$this->attributes['id']] = $this;
$label = __(ucwords(str_replace("_", " ", $this->attributes['id'])));
$validator = new sfValidatorString(array('required' => false));
if ($this->attributes['required'] == "true") {
$label .= "<span class='required'> * </span>";
$validator = new sfValidatorString(array('required' => true), array('required' => 'Add a project to view'));
}
$widgetSchema[$this->attributes['id']]->setLabel($label);
$form->setValidator($this->attributes['id'], $validator);
}
示例12: embedWidgetIntoForm
public function embedWidgetIntoForm(sfForm &$form)
{
$requiredMess = 'Select a location';
$widgetSchema = $form->getWidgetSchema();
$widgetSchema[$this->attributes['id']] = $this;
$label = ucwords(str_replace("_", " ", $this->attributes['id']));
$validator = new sfValidatorString();
if (isset($this->attributes['required']) && $this->attributes['required'] == "true") {
$label .= "<span class='required'> * </span>";
$validator = new sfValidatorString(array('required' => true), array('required' => $requiredMess));
}
$widgetSchema[$this->attributes['id']]->setLabel($label);
$form->setValidator($this->attributes['id'], $validator);
}
示例13: embedWidgetIntoForm
/**
* Embeds this widget into the form. Sets label and validator for this widget.
* @param sfForm $form
*/
public function embedWidgetIntoForm(sfForm &$form)
{
$widgetSchema = $form->getWidgetSchema();
$validatorSchema = $form->getValidatorSchema();
$widgetSchema[$this->attributes['id']] = $this;
$widgetSchema[$this->attributes['id']]->setLabel(ucwords(str_replace("_", " ", $this->attributes['id'])));
$requiredMessage = __(ValidationMessages::REQUIRED);
$validatorSchema[$this->attributes['id']] = new ohrmValidatorConditionalFilter(array(), array('required' => $requiredMessage));
//$form->setValidator('date_period', new sfValidatorString());
// $validatorSchema[$this->attributes['id']] = new ohrmValidatorDateRange(array(), array("invalid" => "Insert a correct date"));
// $validatorSchema[$this->attributes['id']] = new sfValidatorPass();
// $validatorSchema->setPostValidator(new ohrmValidatorSchemaDateRange($this->attributes['id'], ohrmValidatorSchemaDateRange::LESS_THAN_EQUAL, $this->attributes['id'],
// array('throw_global_error' => true),
// array('invalid' => 'The from date ("%left_field%") must be before the to date ("%right_field%")')
// ));
}
示例14: configureWidgetSchema
/**
* Configures some things on the sfWidgetSchema of the form
*/
protected function configureWidgetSchema(sfForm $form)
{
$widgetSchema = $form->getWidgetSchema();
$requiredFields = $form->getRequiredFields();
$widgetSchema->addOption('required_fields', $requiredFields);
$formFormatters = sfSympalConfig::get('form', 'form_formatters', array());
$catalogue = $widgetSchema->getFormFormatter()->getTranslationCatalogue();
foreach ($formFormatters as $name => $class) {
$formFormatter = new $class($widgetSchema);
// persist the translation catalogue
if ($catalogue) {
$formFormatter->setTranslationCatalogue($catalogue);
}
$widgetSchema->addFormFormatter($name, $formFormatter);
}
}
示例15: replaceValidators
public static function replaceValidators(sfForm $form)
{
foreach ($form->getWidgetSchema()->getFields() as $name => $widget) {
if ($widget instanceof mtWidgetFormInputDate) {
$form->setValidator($name, self::getDateValidator());
} elseif ($widget instanceof sfWidgetFormFilterDate) {
$form->getValidator($name)->setOption("from_date", self::getDateValidator(array("required" => false)));
$form->getValidator($name)->setOption("to_date", self::getDateValidator(array("required" => false)));
}
if ($name == "attachment") {
$form->setValidator($name, new sfValidatorFile(array("required" => false, "path" => sfConfig::get("sf_upload_dir"))));
} elseif ($name == "email") {
$form->setValidator($name, new sfValidatorEmail());
}
}
}