本文整理汇总了PHP中sfForm::embedForm方法的典型用法代码示例。如果您正苦于以下问题:PHP sfForm::embedForm方法的具体用法?PHP sfForm::embedForm怎么用?PHP sfForm::embedForm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfForm
的用法示例。
在下文中一共展示了sfForm::embedForm方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: configure
public function configure()
{
$object = $this->getObject();
$this->useFields(array('egreso', 'complicaciones', 'riesgoqx_id', 'contaminacionqx_id', 'eventoqx_id', 'clasificacionqx', 'destino_px', 'status', 'ev_adversos_anestesia'));
//$this->widgetSchema['paciente_id'] = new sfWidgetFormInputHidden();
$this->widgetSchema['egreso'] = new sfWidgetFormInputText();
$this->widgetSchema['complicaciones'] = new sfWidgetFormTextarea();
$this->widgetSchema['status'] = new sfWidgetFormInputHidden();
$this->widgetSchema['status']->setAttribute('value', '100');
$this->setWidget('destino_px', new sfWidgetFormChoice(array('choices' => array('Recuperación', 'Intensivos', 'Sala', 'Defunción'), 'expanded' => true)));
$this->setWidget('clasificacionqx', new sfWidgetFormChoice(array('choices' => array(null, 'Mayor', 'Menor'), 'expanded' => false)));
$this->widgetSchema->setLabels(AgendaPeer::getLabels());
/* Ajustes a los validadores */
$this->validatorSchema['egreso']->setOption('required', true);
$this->validatorSchema['egreso']->setMessage('required', 'Falta hora');
// Agregando las personas del transoperatorio
$this->widgetSchema['egreso']->setAttributes(array('id' => 'datahora'));
$transPersonal = $object->getPersonalTransoperatorio();
$tmp = new sfForm();
if ($transPersonal != null) {
foreach ($transPersonal as $personal) {
if ($personal->getPersonalNombre()) {
$x = new PersonalcirugiaForm($personal);
$x->useFields(array('finaliza', 'personal_nombre'));
$tmp->embedForm('personal' . $personal->getId(), $x);
}
}
$this->embedForm('temporal', $tmp);
}
$this->validatorSchema['clasificacionqx']->setOption('required', true);
$this->validatorSchema['clasificacionqx']->setMessage('required', 'Falta clasificación de la cirugía');
}
示例2: 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);
}
示例3: configure
public function configure()
{
$wrapperForm = new sfForm();
foreach ($this->courseParticipant->ParticipantLessons as $lesson)
{
//$wrapperForm->embedForm($todo->getId(), new TodoForm($todo));
$wrapperForm->embedForm($lesson->getLesson()->getDate(), new embeddedLessonParticipantForm($lesson));
}
$this->embedForm('participantLessons', $wrapperForm);
$this->widgetSchema->setNameFormat('participant_course_abseces[%s]');
}
示例4: configure
public function configure()
{
$subForm = new sfForm();
foreach ($this->options['collection'] as $index => $record) {
if ($this->options['level'] == Users::REGISTERED_USER && $record->getCollections() == ',' && $record->getAllPublic() === false) {
} else {
$form = new MyWidgetsForm($record, array('level' => $this->options['level']));
$subForm->embedForm($index, $form);
}
}
$this->embedForm('MyWidgets', $subForm);
$this->widgetSchema->setNameFormat('user_widget[%s]');
}
示例5: configure
public function configure()
{
$q = Doctrine_Core::getTable('ScssScout')->createQuery('s')->leftJoin('s.Patrol p')->where('p.troop_id = ?', sfContext::getInstance()->getUser()->getProfile()->getActiveEnrollment()->getTroop()->getId())->orderBy('s.last_name, s.first_name ASC');
$this->widgetSchema['scout_id'] = new sfWidgetFormDoctrineChoice(array('model' => 'ScssScout', 'query' => $q));
$scout = new ScssScout();
$sForm = new sfForm();
$pMax = sfContext::getInstance()->getUser()->getProfile()->getActiveEnrollment()->getWeek()->getPeriods();
foreach ($pMax as $i => $period) {
$enroll = new ScssScoutEnrollment();
$enroll->Scout = $scout;
$form = new ScssScoutEnrollmentForm($enroll, array('period' => $period));
$sForm->embedForm($i, $form);
}
$this->embedForm('ClassesByPeriod', $sForm);
}
示例6: configure
public function configure()
{
$subForm = new sfForm();
if (isset($this->options['no_load'])) {
$keywords = array();
} else {
$keywords = Doctrine::getTable('ClassificationKeywords')->findForTable($this->options['table'], $this->options['id']);
}
foreach ($keywords as $index => $childObject) {
$form = new ClassificationKeywordsForm($childObject);
$subForm->embedForm($index, $form);
}
$this->embedForm('ClassificationKeywords', $subForm);
$subForm2 = new sfForm();
$this->embedForm('newKeywords', $subForm2);
$this->widgetSchema->setNameFormat('keywords[%s]');
}
示例7: configure
public function configure()
{
$num_votos = 5;
unset($this['created_at'], $this['updated_at'], $this['parlamentario_list']);
if (sfContext::getInstance()->getRouting()->getCurrentRouteName() == 'votacion_comision_edit') {
$this->embedRelation('VotacionComisionParlamentario AS Voto');
} else {
$subForm = new sfForm();
for ($i = 0; $i < $num_votos; $i++) {
$VotacionParlamentario = new VotacionComisionParlamentario();
$VotacionParlamentario->VotacionComision = $this->getObject();
$form = new VotacionComisionParlamentarioForm($VotacionParlamentario);
$subForm->embedForm($i, $form);
}
$this->embedForm('Voto', $subForm);
}
}
示例8: configure
public function configure()
{
$subForm = new sfForm();
if (isset($this->options['no_load'])) {
$names = array();
} else {
$names = Doctrine::getTable('VernacularNames')->findForTable($this->options['table'], $this->options['id']);
}
foreach ($names as $index => $childObject) {
$form = new VernacularNamesForm($childObject);
$subForm->embedForm($index, $form);
}
$this->embedForm('VernacularNames', $subForm);
$subForm2 = new sfForm();
$this->embedForm('newVal', $subForm2);
$this->widgetSchema->setNameFormat('grouped_vernacular[%s]');
}
示例9: configure
public function configure()
{
$subForm = new sfForm();
if (isset($this->options['no_load'])) {
$items = array();
} else {
$items = Doctrine::getTable('LoanItems')->findForLoan($this->options['loan']->getId());
}
foreach ($items as $index => $childObject) {
$form = new LoanItemsForm($childObject);
$subForm->embedForm($index, $form);
}
$this->embedForm('LoanItems', $subForm);
$subForm2 = new sfForm();
$this->embedForm('newLoanItems', $subForm2);
$this->widgetSchema->setNameFormat('loan_overview[%s]');
}
示例10: configure
public function configure()
{
$subForm = new sfForm();
$collections = Doctrine::getTable('Collections')->fetchByCollectionParent($this->options['current_user'], $this->options['user_ref'], $this->options['collection_ref']);
foreach ($collections as $record) {
if (count($record->CollectionsRights)) {
$right = $record->CollectionsRights[0];
} else {
$right = new CollectionsRights();
$right->setCollectionRef($record->getId());
$right->setDbUserType(0);
$right->setUserRef($this->options['user_ref']);
}
$form = new SubCollectionsRightsForm($right, array('collection' => $record));
$subForm->embedForm($record->getId(), $form);
}
$this->embedForm('collections', $subForm);
$this->widgetSchema->setNameFormat('sub_collection[%s]');
}
示例11: embedDetalles
protected function embedDetalles()
{
$detalles_forms = new sfForm();
if (false === sfContext::getInstance()->getRequest()->isXmlHttpRequest()) {
$detalles_solicitudes = $this->getObject()->getDetalleSolicitud();
if (count($detalles_solicitudes) == 0) {
for ($i = 0; $i < 1; $i++) {
$detalle_solicitud = new detalle_solicitud();
$detalle_solicitud->solicitud_id = $this->getObject();
$detalles_solicitudes[] = $detalle_solicitud;
}
}
foreach ($detalles_solicitudes as $key => $v) {
$detalle_solicitud_form = new detalle_solicitudForm($v);
$detalles_forms->embedForm('Articulo ' . ($key + 1), $detalle_solicitud_form);
$detalles_forms->widgetSchema['Articulo ' . ($key + 1)]->setLabel('Artículo ' . ($key + 1));
}
}
$this->embedForm('Articulos', $detalles_forms);
$this->widgetSchema['Articulos']->setLabel('Artículos Solicitados');
}
示例12: configure
public function configure()
{
$this->useFields(array('version', 'summary', 'stability', 'api_versions_list'));
if ($plugin = $this->getOption('plugin')) {
$this->widgetSchema['plugin_id'] = new sfWidgetFormInputHidden();
$this->setDefault('plugin_id', $plugin->id);
}
$this->setDefault('date', date('Y-m-d H:i:s'));
$this->validatorSchema['version'] = new sfValidatorVersion();
$apiVersions = Doctrine::getTable('SymfonyApiVersion')->findAll();
$choices = $apiVersions->toKeyValueArray('id', 'name');
$this->mergeWidgets(array('date' => new sfWidgetFormInputHidden(), 'api_versions_list' => new sfWidgetFormChoice(array('choices' => $choices, 'multiple' => true, 'expanded' => true))));
// Embed Dependencies
$dependencyForm = new sfForm();
foreach ($this->object['Dependencies'] as $i => $dependency) {
$dependencyForm->embedForm('dependency_' . $i, new PluginReleaseDependencyForm($dependency));
}
$this->embedForm('dependencies', $dependencyForm);
// Set Labels
$this->widgetSchema->setLabels(array('api_versions_list' => 'Api Versions'));
}
示例13: catch
$t->fail('renderUsing() throws an exception if formatter name does not exist');
} catch (InvalidArgumentException $e) {
$t->pass('renderUsing() throws an exception if formatter name does not exist');
}
// renderHiddenFields()
$t->diag('->renderHiddenFields()');
$f = new sfForm();
$f->setWidgets(array('id' => new sfWidgetFormInputHidden(), 'name' => new sfWidgetFormInputText(), 'is_admin' => new sfWidgetFormInputHidden()));
$output = '<input type="hidden" name="id" id="id" /><input type="hidden" name="is_admin" id="is_admin" />';
$t->is($f->renderHiddenFields(), $output, 'renderHiddenFields() renders all hidden fields, no visible fields');
$t->is(count($f->getFormFieldSchema()), 3, 'renderHiddenFields() does not modify the form fields');
$author = new sfForm();
$author->setWidgets(array('id' => new sfWidgetFormInputHidden(), 'name' => new sfWidgetFormInputText()));
$company = new sfForm();
$company->setWidgets(array('id' => new sfWidgetFormInputHidden(), 'name' => new sfWidgetFormInputText()));
$author->embedForm('company', $company);
$output = '<input type="hidden" name="id" id="id" /><input type="hidden" name="company[id]" id="company_id" />';
$t->is($author->renderHiddenFields(), $output, 'renderHiddenFields() renders hidden fields from embedded forms');
$output = '<input type="hidden" name="id" id="id" />';
$t->is($author->renderHiddenFields(false), $output, 'renderHiddenFields() does not render hidden fields from embedded forms if the first parameter is "false"');
// ->embedForm()
$t->diag('->embedForm()');
$author = new FormTest(array('first_name' => 'Fabien'));
$author->setWidgetSchema($author_widget_schema = new sfWidgetFormSchema(array('first_name' => new sfWidgetFormInputText())));
$author->setValidatorSchema($author_validator_schema = new sfValidatorSchema(array('first_name' => new sfValidatorString(array('min_length' => 2)))));
$company = new FormTest();
$company->setWidgetSchema($company_widget_schema = new sfWidgetFormSchema(array('name' => new sfWidgetFormInputText())));
$company->setValidatorSchema($company_validator_schema = new sfValidatorSchema(array('name' => new sfValidatorString(array('min_length' => 2)))));
$article = new FormTest();
$article->setWidgetSchema($article_widget_schema = new sfWidgetFormSchema(array('title' => new sfWidgetFormInputText())));
$article->setValidatorSchema($article_validator_schema = new sfValidatorSchema(array('title' => new sfValidatorString(array('min_length' => 2)))));
示例14: embedRelation
/**
* Embed a Doctrine_Collection relationship in to a form
*
* [php]
* $userForm = new UserForm($user);
* $userForm->embedRelation('Groups AS groups');
*
* @param string $relationName The name of the relation and an optional alias
* @param string $formClass The name of the form class to use
* @param array $formArguments Arguments to pass to the constructor (related object will be shifted onto the front)
* @param string $innerDecorator A HTML decorator for each embedded form
* @param string $decorator A HTML decorator for the main embedded form
*
* @throws InvalidArgumentException If the relationship is not a collection
*/
public function embedRelation($relationName, $formClass = null, $formArgs = array(), $innerDecorator = null, $decorator = null)
{
if (false !== ($pos = stripos($relationName, ' as '))) {
$fieldName = substr($relationName, $pos + 4);
$relationName = substr($relationName, 0, $pos);
} else {
$fieldName = $relationName;
}
$relation = $this->getObject()->getTable()->getRelation($relationName);
$r = new ReflectionClass(null === $formClass ? $relation->getClass() . 'Form' : $formClass);
if (Doctrine_Relation::ONE == $relation->getType()) {
$this->embedForm($fieldName, $r->newInstanceArgs(array_merge(array($this->getObject()->{$relationName}), $formArgs)), $decorator);
} else {
$subForm = new sfForm();
foreach ($this->getObject()->{$relationName} as $index => $childObject) {
$form = $r->newInstanceArgs(array_merge(array($childObject), $formArgs));
$subForm->embedForm($index, $form, $innerDecorator);
$subForm->getWidgetSchema()->setLabel($index, (string) $childObject);
}
$this->embedForm($fieldName, $subForm, $decorator);
}
}
示例15: embedRelation
/**
* Embed a Doctrine_Collection relationship in to a form
*
* [php]
* $userForm = new UserForm($user);
* $userForm->embedRelation('Groups');
*
* @param string $relationName The name of the relation
* @param string $formClass The name of the form class to use
* @param array $formArguments Arguments to pass to the constructor (related object will be shifted onto the front)
*
* @throws InvalidArgumentException If the relationship is not a collection
*/
public function embedRelation($relationName, $formClass = null, $formArgs = array())
{
// FIXME: Where exactly is getTable() declared?
// It triggers __call() which retrieves a property called $table,
// which doesn't seem to be declared anywhere so it triggers __get()
// which then again tries to call getTable() (if it exists) or
// returns $this->table, which eventually doesn't exists?
// I don't think this is works
throw new sfException('Not implemented');
$relation = $this->object->getTable()->getRelation($relationName);
if ($relation->getType() !== Doctrine_Relation::MANY) {
throw new InvalidArgumentException('You can only embed a relationship that is a collection.');
}
$r = new ReflectionClass(null === $formClass ? $relation->getClass() . 'Form' : $formClass);
$subForm = new sfForm();
foreach ($this->object[$relationName] as $index => $childObject) {
$form = $r->newInstanceArgs(array_merge(array($childObject), $formArgs));
$subForm->embedForm($index, $form);
$subForm->getWidgetSchema()->setLabel($index, (string) $childObject);
}
$this->embedForm($relationName, $subForm);
}