本文整理汇总了PHP中FabrikWorker::formDefaults方法的典型用法代码示例。如果您正苦于以下问题:PHP FabrikWorker::formDefaults方法的具体用法?PHP FabrikWorker::formDefaults怎么用?PHP FabrikWorker::formDefaults使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FabrikWorker
的用法示例。
在下文中一共展示了FabrikWorker::formDefaults方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createLinkedForm
/**
* When saving a list that links to a database for the first time we
* automatically create a form to allow the update/creation of that tables
* records
*
* @param int $formId to copy from. If = 0 then create a default form. If not 0 then copy the form id passed in
*
* @return object form model
*/
private function createLinkedForm($formId = 0)
{
$this->getFormModel();
if ($formId == 0) {
/**
* $$$ rob required otherwise the JTable is loaed with db_table_name as a property
* which then generates an error - not sure why its loaded like that though?
* 18/08/2011 - could be due to the Form table class having it in its bind method
* - (have now overridden form table store() to remove thoes two params)
*/
$this->formModel->getForm();
jimport('joomla.utilities.date');
$createDate = JFactory::getDate();
$createDate = $createDate->toSql();
$form = $this->getTable('Form');
$item = $this->getTable('List');
$defaults = FabrikWorker::formDefaults('form');
$form->bind($defaults);
$form->set('label', $item->get('label'));
$form->set('record_in_database', 1);
$form->set('created', $createDate);
$form->set('created_by', $this->user->get('id'));
$form->set('created_by_alias', $this->user->get('username'));
$form->set('error', FText::_('COM_FABRIK_FORM_ERROR_MSG_TEXT'));
$form->set('submit_button_label', FText::_('COM_FABRIK_SAVE'));
$form->set('published', $item->get('published'));
$version = new JVersion();
$form->set('form_template', version_compare($version->RELEASE, '3.0') >= 0 ? 'bootstrap' : 'default');
$form->set('view_only_template', version_compare($version->RELEASE, '3.0') >= 0 ? 'bootstrap' : 'default');
$form->store();
$this->setState('list.form_id', $form->get('id'));
$this->formModel->setId($form->get('id'));
} else {
$this->setState('list.form_id', $formId);
$this->formModel->setId($formId);
$this->formModel->getTable();
$this->formModel->copy();
}
$this->formModel->getForm();
return $this->formModel;
}
示例2: createLinkedForm
/**
* When saving a list that links to a database for the first time we
* automatically create a form to allow the update/creation of that tables
* records
*
* @param int $formid to copy from. If = 0 then create a default form. If not 0 then copy the form id passed in
*
* @return object form model
*/
private function createLinkedForm($formid = 0)
{
$config = JFactory::getConfig();
$user = JFactory::getUser();
$this->getFormModel();
if ($formid == 0) {
/**
* $$$ rob required otherwise the JTable is loaed with db_table_name as a property
* which then generates an error - not sure why its loaded like that though?
* 18/08/2011 - could be due to the Form table class having it in its bind method
* - (have now overridden form table store() to remove thoes two params)
*/
$this->formModel->getForm();
jimport('joomla.utilities.date');
$createdate = JFactory::getDate();
$createdate = $createdate->toSql();
$form = $this->getTable('Form');
$item = $this->getTable('List');
$defaults = FabrikWorker::formDefaults('form');
$form->bind($defaults);
$form->label = $item->label;
$form->record_in_database = 1;
$form->created = $createdate;
$form->created_by = $user->get('id');
$form->created_by_alias = $user->get('username');
$form->error = JText::_('COM_FABRIK_FORM_ERROR_MSG_TEXT');
$form->submit_button_label = JText::_('COM_FABRIK_SAVE');
$form->published = $item->published;
$form->form_template = 'default';
$form->view_only_template = 'default';
if (!$form->store()) {
return JError::raiseError(500, $form->getError());
}
$this->setState('list.form_id', $form->id);
$this->formModel->setId($form->id);
} else {
$this->setState('list.form_id', $formid);
$this->formModel->setId($formid);
$this->formModel->getTable();
if (!$this->formModel->copy()) {
return JError::raiseError(500, $form->getError());
}
}
$this->formModel->getForm();
return $this->formModel;
}