Skip to content

Commit

Permalink
chore: lab to hide fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Thulin committed Mar 11, 2024
1 parent 038562c commit 5942634
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
10 changes: 9 additions & 1 deletion source/php/AcfFields/json/event-fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@
"type": "textarea",
"instructions": "",
"required": 1,
"conditional_logic": 0,
"conditional_logic": [
[
{
"field": "field_65a5319a9d01d",
"operator": "==",
"value": "https"
}
]
],
"wrapper": {
"width": "",
"class": "",
Expand Down
10 changes: 9 additions & 1 deletion source/php/AcfFields/php/event-fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@
'type' => 'textarea',
'instructions' => '',
'required' => 1,
'conditional_logic' => 0,
'conditional_logic' => array(
0 => array(
0 => array(
'field' => 'field_65a5319a9d01d',
'operator' => '==',
'value' => 'https',
),
),
),
'wrapper' => array(
'width' => '',
'class' => '',
Expand Down
24 changes: 22 additions & 2 deletions source/php/FieldSettingHidePublic.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,35 @@ public function addPublicFieldOption($field) {
}

public function hideFieldFromFrontendForms($field) {



//Set default
if (!isset($field['is_publicly_hidden'])) {
$field['is_publicly_hidden'] = 0;
}

// Do not hide fields in admin
if(is_admin()) {
return $field;
}

//Hide field from frontend forms
if ($field['is_publicly_hidden'] == 1) {
return false;

//Will generate offset error
//return false;


//Make a impossible statement to test if the field is hidden?
$field['conditional_logic'] = [
[
"field" => "field_fake_field_id",
"operator" => "!=",
"value" => "fake_value"
]
];
var_dump($field);

}

return $field;
Expand Down

0 comments on commit 5942634

Please sign in to comment.