Skip to content

Commit

Permalink
Fix a bug, Restore Validation panel, more rebrand updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bd-viget committed Jan 24, 2025
1 parent 318220f commit 38f1a39
Show file tree
Hide file tree
Showing 14 changed files with 117 additions and 32 deletions.
4 changes: 2 additions & 2 deletions blocks/checkbox/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
},
"style": "file:./style.css",
"providesContext": {
"acffb/fieldId": "blockId"
"vgtfb/fieldId": "blockId"
},
"usesContext": ["acffb/formId", "acffb/fieldsetId"],
"usesContext": ["vgtfb/formId", "vgtfb/fieldsetId"],
"acf": {
"mode": "preview"
}
Expand Down
4 changes: 2 additions & 2 deletions blocks/fieldset/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
}
},
"providesContext": {
"acffb/fieldsetId": "blockId"
"vgtfb/fieldsetId": "blockId"
},
"usesContext": ["acffb/formId"],
"usesContext": ["vgtfb/formId"],
"styles": [
{ "name": "default", "label": "List", "isDefault": true },
{ "name": "inline", "label": "Inline" },
Expand Down
2 changes: 1 addition & 1 deletion blocks/form/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}
},
"providesContext": {
"acffb/formId": "blockId"
"vgtfb/formId": "blockId"
},
"acf": {
"mode": "preview"
Expand Down
4 changes: 2 additions & 2 deletions blocks/input/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"anchor": true
},
"providesContext": {
"acffb/fieldId": "blockId"
"vgtfb/fieldId": "blockId"
},
"style": "file:./style.css",
"attributes": {
Expand Down Expand Up @@ -142,7 +142,7 @@
"isActive": ["data"]
}
],
"usesContext": ["acffb/formId", "acffb/fieldsetId"],
"usesContext": ["vgtfb/formId", "vgtfb/fieldsetId"],
"acf": {
"mode": "preview"
}
Expand Down
2 changes: 1 addition & 1 deletion blocks/label/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}
},
"style": "file:./style.css",
"usesContext": ["acffb/formId", "acffb/fieldId"],
"usesContext": ["vgtfb/formId", "vgtfb/fieldId"],
"acf": {
"mode": "preview"
}
Expand Down
2 changes: 1 addition & 1 deletion blocks/legend/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"default": ""
}
},
"usesContext": ["acffb/formId", "acffb/fieldsetId"],
"usesContext": ["vgtfb/formId", "vgtfb/fieldsetId"],
"acf": {
"mode": "preview"
}
Expand Down
4 changes: 2 additions & 2 deletions blocks/radios/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
}
},
"providesContext": {
"acffb/fieldId": "blockId"
"vgtfb/fieldId": "blockId"
},
"usesContext": ["acffb/formId", "acffb/fieldsetId"],
"usesContext": ["vgtfb/formId", "vgtfb/fieldsetId"],
"acf": {
"mode": "preview"
}
Expand Down
4 changes: 2 additions & 2 deletions blocks/select/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
"default": ""
}
},
"usesContext": ["acffb/formId", "acffb/fieldsetId"],
"usesContext": ["vgtfb/formId", "vgtfb/fieldsetId"],
"providesContext": {
"acffb/fieldId": "blockId"
"vgtfb/fieldId": "blockId"
},
"acf": {
"mode": "preview"
Expand Down
2 changes: 1 addition & 1 deletion blocks/submit/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"default": ""
}
},
"usesContext": ["acffb/formId", "acffb/fieldsetId"],
"usesContext": ["vgtfb/formId", "vgtfb/fieldsetId"],
"acf": {
"mode": "preview"
}
Expand Down
4 changes: 2 additions & 2 deletions blocks/textarea/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"default": ""
}
},
"usesContext": ["acffb/formId", "acffb/fieldsetId"],
"usesContext": ["vgtfb/formId", "vgtfb/fieldsetId"],
"providesContext": {
"acffb/fieldId": "blockId"
"vgtfb/fieldId": "blockId"
},
"acf": {
"mode": "preview"
Expand Down
10 changes: 5 additions & 5 deletions classes/Elements/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public function set_context( array $new_context ): void {
* @return ?Form
*/
public function get_form(): ?Form {
return Form::find_form( $this->get_context( 'acffb/formId' ) );
return Form::find_form( $this->get_context( 'vgtfb/formId' ) );
}

/**
Expand All @@ -214,11 +214,11 @@ public function get_form(): ?Form {
* @return ?Field
*/
public function get_fieldset(): ?Field {
if ( ! $this->get_context( 'acffb/fieldsetId' ) ) {
if ( ! $this->get_context( 'vgtfb/fieldsetId' ) ) {
return null;
}

$fieldset_id = 'acf_field_' . $this->get_context( 'acffb/fieldsetId' );
$fieldset_id = 'acf_field_' . $this->get_context( 'vgtfb/fieldsetId' );
return $this->get_form()?->get_form_object()->get_field_by_id( $fieldset_id );
}

Expand All @@ -228,11 +228,11 @@ public function get_fieldset(): ?Field {
* @return ?Field
*/
public function get_parent_field(): ?Field {
if ( ! $this->get_context( 'acffb/fieldId' ) ) {
if ( ! $this->get_context( 'vgtfb/fieldId' ) ) {
return null;
}

$input_id = 'acf_field_' . $this->get_context( 'acffb/fieldId' );
$input_id = 'acf_field_' . $this->get_context( 'vgtfb/fieldId' );

return $this->get_form()?->get_form_object()->get_field_by_id( $input_id );
}
Expand Down
2 changes: 1 addition & 1 deletion classes/Elements/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public function get_all_fields( string $content = '', array $context = [] ): arr
public function update_field_context(): void {
$fields = $this->get_all_fields();
$context = [
'acffb/formId' => $this->get_id(),
'vgtfb/formId' => $this->get_id(),
];

foreach ( $fields as $field ) {
Expand Down
6 changes: 5 additions & 1 deletion classes/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,11 @@ public static function get_all_forms(): array {
*/
public static function find_form( ?string $form_id = null ): ?Form {
if ( is_null( $form_id ) ) {
return self::get_instance( $form_id );
return self::get_instance();
}

if ( ! str_starts_with( $form_id, 'acf_form_' ) ) {
$form_id = 'acf_form_' . $form_id;
}

foreach ( self::get_all_forms() as $form ) {
Expand Down
99 changes: 90 additions & 9 deletions includes/block-fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,87 @@ function() {
return;
}

acf_add_local_field_group( array(
'key' => 'group_6793a80e4d167',
'title' => 'Validation',
'fields' => array(
array(
'key' => 'field_6793a80e01b0b',
'label' => 'Required',
'name' => 'required',
'aria-label' => '',
'type' => 'true_false',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'message' => '',
'default_value' => 0,
'allow_in_bindings' => 0,
'ui_on_text' => '',
'ui_off_text' => '',
'ui' => 1,
),
),
'location' => array(
array(
array(
'param' => 'block',
'operator' => '==',
'value' => 'acf/input',
),
),
array(
array(
'param' => 'block',
'operator' => '==',
'value' => 'acf/select',
),
),
array(
array(
'param' => 'block',
'operator' => '==',
'value' => 'acf/textarea',
),
),
array(
array(
'param' => 'block',
'operator' => '==',
'value' => 'acf/checkbox',
),
),
array(
array(
'param' => 'block',
'operator' => '==',
'value' => 'acf/fieldset',
),
),
array(
array(
'param' => 'block',
'operator' => '==',
'value' => 'acf/radios',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => true,
'description' => '',
'show_in_rest' => 1,
) );

acf_add_local_field_group( array(
'key' => 'group_6683facdcf97c',
'title' => 'Block: Field',
Expand Down Expand Up @@ -73,7 +154,7 @@ function() {
'hide_on_screen' => '',
'active' => true,
'description' => '',
'show_in_rest' => 0,
'show_in_rest' => 1,
) );

acf_add_local_field_group( array(
Expand Down Expand Up @@ -539,7 +620,7 @@ function() {
'hide_on_screen' => '',
'active' => true,
'description' => '',
'show_in_rest' => 0,
'show_in_rest' => 1,
) );

acf_add_local_field_group( array(
Expand Down Expand Up @@ -629,7 +710,7 @@ function() {
'hide_on_screen' => '',
'active' => true,
'description' => '',
'show_in_rest' => 0,
'show_in_rest' => 1,
) );

acf_add_local_field_group( array(
Expand Down Expand Up @@ -719,7 +800,7 @@ function() {
'hide_on_screen' => '',
'active' => true,
'description' => '',
'show_in_rest' => 0,
'show_in_rest' => 1,
) );

acf_add_local_field_group( array(
Expand Down Expand Up @@ -764,7 +845,7 @@ function() {
'hide_on_screen' => '',
'active' => true,
'description' => '',
'show_in_rest' => 0,
'show_in_rest' => 1,
) );

acf_add_local_field_group( array(
Expand Down Expand Up @@ -837,7 +918,7 @@ function() {
'hide_on_screen' => '',
'active' => true,
'description' => '',
'show_in_rest' => 0,
'show_in_rest' => 1,
) );

acf_add_local_field_group( array(
Expand Down Expand Up @@ -1065,7 +1146,7 @@ function() {
'hide_on_screen' => '',
'active' => true,
'description' => '',
'show_in_rest' => 0,
'show_in_rest' => 1,
) );

acf_add_local_field_group( array(
Expand Down Expand Up @@ -1213,7 +1294,7 @@ function() {
'hide_on_screen' => '',
'active' => true,
'description' => '',
'show_in_rest' => 0,
'show_in_rest' => 1,
) );

acf_add_local_field_group( array(
Expand Down Expand Up @@ -1460,7 +1541,7 @@ function() {
'hide_on_screen' => '',
'active' => true,
'description' => '',
'show_in_rest' => 0,
'show_in_rest' => 1,
) );
} );
}
Expand Down

0 comments on commit 38f1a39

Please sign in to comment.