本文整理汇总了PHP中SectionManager::createSectionAssociation方法的典型用法代码示例。如果您正苦于以下问题:PHP SectionManager::createSectionAssociation方法的具体用法?PHP SectionManager::createSectionAssociation怎么用?PHP SectionManager::createSectionAssociation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SectionManager
的用法示例。
在下文中一共展示了SectionManager::createSectionAssociation方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createSectionAssociation
/**
* Create an association between a section and a field.
*
* @deprecated This function will be removed in a future Symphony release,
* Use `SectionManager::createSectionAssociation` instead.
* @param integer $parent_section_id
* The linked section id.
* @param integer $child_field_id
* The field ID of the field that is creating the association
* @param integer $parent_field_id (optional)
* The field ID of the linked field in the linked section
* @param boolean $show_association (optional)
* Whether of not the link should be shown on the entries table of the
* linked section. This defaults to true.
* @return boolean
* true if the association was successfully made, false otherwise.
*/
public function createSectionAssociation($parent_section_id = null, $child_field_id = null, $parent_field_id = null, $show_association = true)
{
return SectionManager::createSectionAssociation($parent_section_id, $child_field_id, $parent_field_id, $show_association);
}
示例2: commit
public function commit()
{
if (!parent::commit()) {
return false;
}
$id = $this->get('id');
if ($id === false) {
return false;
}
$fields = array();
$fields['pre_populate_source'] = is_null($this->get('pre_populate_source')) ? null : implode(',', $this->get('pre_populate_source'));
$fields['validator'] = $fields['validator'] == 'custom' ? null : $this->get('validator');
if (!FieldManager::saveSettings($id, $fields)) {
return false;
}
SectionManager::removeSectionAssociation($id);
foreach ($this->get('pre_populate_source') as $field_id) {
if ($field_id === 'none') {
continue;
}
if (!is_null($field_id) && is_numeric($field_id)) {
SectionManager::createSectionAssociation(null, $id, (int) $field_id, $this->get('show_association') == 'yes' ? true : false, $this->get('association_ui'), $this->get('association_editor'));
}
}
return true;
}
示例3: commit
/**
*
* Save field settings into the field's table
*/
public function commit()
{
// if the default implementation works...
if (!parent::commit()) {
return false;
}
$id = $this->get('id');
// exit if there is no id
if ($id == false) {
return false;
}
// we are the child, with multiple parents
$child_field_id = $id;
// delete associations, only where we are the child
self::removeSectionAssociation($child_field_id);
$sections = $this->getSelectedSectionsArray();
foreach ($sections as $key => $sectionId) {
if (empty($sectionId)) {
continue;
}
$parent_section_id = General::intval($sectionId);
$parent_section = SectionManager::fetch($sectionId);
$fields = $parent_section->fetchVisibleColumns();
if (empty($fields)) {
// no visible field, revert to all
$fields = $parent_section->fetchFields();
}
$parent_field_id = current(array_keys($fields));
// create association
SectionManager::createSectionAssociation($parent_section_id, $child_field_id, $parent_field_id, $this->get('show_association') == 'yes');
}
// declare an array contains the field's settings
$settings = array('sections' => $this->get('sections'), 'show_association' => $this->get('show_association'), 'deepness' => $this->get('deepness'), 'elements' => $this->get('elements'), 'mode' => $this->get('mode'), 'min_entries' => $this->get('min_entries'), 'max_entries' => $this->get('max_entries'), 'allow_new' => $this->get('allow_new'), 'allow_edit' => $this->get('allow_edit'), 'allow_link' => $this->get('allow_link'), 'allow_delete' => $this->get('allow_delete'));
return FieldManager::saveSettings($id, $settings);
}
示例4: commit
/**
* Save the settings panel
*
* @return bool
*/
public function commit()
{
if (!parent::commit()) {
return false;
}
$id = $this->get('id');
if ($id === false) {
return false;
}
if ($this->get('related_field_id') != '') {
$settings['related_field_id'] = $this->get('related_field_id');
}
$settings['allow_multiple_selection'] = $this->get('allow_multiple_selection') ? $this->get('allow_multiple_selection') : 'no';
$settings['show_association'] = $this->get('show_association') == 'yes' ? 'yes' : 'no';
$settings['limit'] = max(1, (int) $this->get('limit'));
$settings['related_field_id'] = implode(',', $this->get('related_field_id'));
$settings['view'] = $this->get('view');
$settings['show_created'] = $this->get('show_created') == 'yes' ? 1 : 0;
$settings['enable_create'] = $this->get('enable_create') == 'yes' ? 1 : 0;
$settings['enable_edit'] = $this->get('enable_edit') == 'yes' ? 1 : 0;
$settings['enable_delete'] = $this->get('enable_delete') == 'yes' ? 1 : 0;
FieldManager::saveSettings($id, $settings);
SectionManager::removeSectionAssociation($id);
foreach ($this->get('related_field_id') as $field_id) {
SectionManager::createSectionAssociation(null, $id, $field_id, $this->get('show_association') == 'yes' ? true : false);
}
return true;
}
示例5: commit
public function commit()
{
if (!parent::commit()) {
return false;
}
$id = $this->get('id');
if ($id === false) {
return false;
}
$fields = array();
if ($this->get('static_options') != '') {
$fields['static_options'] = $this->get('static_options');
}
if ($this->get('dynamic_options') != '') {
$fields['dynamic_options'] = $this->get('dynamic_options');
}
$fields['allow_multiple_selection'] = $this->get('allow_multiple_selection') ? $this->get('allow_multiple_selection') : 'no';
$fields['sort_options'] = $this->get('sort_options') == 'yes' ? 'yes' : 'no';
if (!FieldManager::saveSettings($id, $fields)) {
return false;
}
SectionManager::removeSectionAssociation($id);
// Dynamic Options isn't an array like in Select Box Link
$field_id = $this->get('dynamic_options');
if (!is_null($field_id) && is_numeric($field_id)) {
SectionManager::createSectionAssociation(null, $id, (int) $field_id, $this->get('show_association') == 'yes' ? true : false, $this->get('association_ui'), $this->get('association_editor'));
}
return true;
}
示例6: commit
public function commit()
{
if (!parent::commit()) {
return false;
}
$id = $this->get('id');
if ($id === false) {
return false;
}
$fields = array();
$fields['field_id'] = $id;
if ($this->get('related_field_id') != '') {
$fields['related_field_id'] = $this->get('related_field_id');
}
$fields['related_field_id'] = implode(',', $this->get('related_field_id'));
$fields['allow_multiple_selection'] = $this->get('allow_multiple_selection') ? $this->get('allow_multiple_selection') : 'no';
$fields['hide_when_prepopulated'] = $this->get('hide_when_prepopulated') == 'yes' ? 'yes' : 'no';
$fields['limit'] = max(0, (int) $this->get('limit'));
if (!FieldManager::saveSettings($id, $fields)) {
return false;
}
SectionManager::removeSectionAssociation($id);
foreach ($this->get('related_field_id') as $field_id) {
SectionManager::createSectionAssociation(null, $id, (int) $field_id, $this->get('show_association') == 'yes' ? true : false, $this->get('association_ui'), $this->get('association_editor'));
}
return true;
}
示例7: commit
public function commit()
{
if (!Field::commit()) {
return false;
}
$id = $this->get('id');
if ($id === false) {
return false;
}
// set field instance values
$fields = array();
$fields['field_id'] = $id;
if (!is_null($this->get('related_field_id'))) {
$fields['related_field_id'] = implode(',', $this->get('related_field_id'));
}
$fields['allow_multiple_selection'] = $this->get('allow_multiple_selection') ? $this->get('allow_multiple_selection') : 'no';
$fields['show_association'] = $this->get('show_association') == 'yes' ? 'yes' : 'no';
$fields['limit'] = max(1, (int) $this->get('limit'));
$fields['field_type'] = $this->get('field_type') ? $this->get('field_type') : 'select';
// save/replace field instance
if (!FieldManager::saveSettings($id, $fields)) {
return false;
}
// build associations
SectionManager::removeSectionAssociation($id);
foreach ($this->get('related_field_id') as $field_id) {
SectionManager::createSectionAssociation(NULL, $id, $field_id, $this->get('show_association') == 'yes' ? true : false);
}
return true;
}