Skip to content

Commit

Permalink
Don’t show options unless the field exists, and is assigned to a chan…
Browse files Browse the repository at this point in the history
…nel or field group
  • Loading branch information
litzinger committed Mar 5, 2021
1 parent 084cb28 commit ae74834
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions ft.entry_type.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,16 @@ protected function fieldsByGroup($group_id = false, bool $exclude_field_id = fal
*/
public function display_settings($settings = [])
{
if (!$this->field_id) {
return ['field_options_entry_type' => [
'label' => 'field_options',
'group' => 'entry_type',
'settings' => [
'This field must first be created and assigned to a Field Group or Channel, then edit the field to change it\'s options.'
]
]];
}

ee()->load->library('entry_type');
ee()->load->helper('array');

Expand All @@ -327,6 +337,7 @@ public function display_settings($settings = [])
} else {
$this->field_id = ee()->uri->segment(4);

/** @var CI_DB_result $query */
$query = ee()->db->select('group_id')
->from('channel_field_groups_fields')
->where('field_id', $this->field_id)
Expand Down Expand Up @@ -362,6 +373,16 @@ public function display_settings($settings = [])
$vars['fields'] = $this->fieldsByChannel($this->settings['field_id'], $this->field_id);
}

if (empty($vars['fields'])) {
return ['field_options_entry_type' => [
'label' => 'field_options',
'group' => 'entry_type',
'settings' => [
'This field must first be assigned to a Field Group or Channel, then edit the field to change it\'s options.'
]
]];
}

if (empty($settings['type_options'])) {
$vars['type_options'] = [
'' => [
Expand Down

0 comments on commit ae74834

Please sign in to comment.