Purpose
Modify the form fields after the entry data has been loaded into them.
This is the counterpart to wr_form_factory_modify_form_fields, which fires at factory time — before an entry exists. Any value set at factory time is reset when the entry is loaded (fields without a database column end up as null). Values set in wr_form_fields_after_entry_load survive into rendering, and readonly hashes are computed over the final value.
Usage
add_filter( 'wr_form_fields_after_entry_load', array( $this, 'adjust_loaded_fields' ), 10, 2 );Parameters
$fields (FormField[]): The form’s fields, already populated with the loaded entry values.$form (Form): The form the entry was loaded into.
Return the (modified) FormField[] array.
Use Case
- Derive a display value from the loaded entry (e.g. compose a label out of several columns).
- Show, hide or reconfigure fields depending on the state of the loaded entry.
Implementation Example
public function adjust_loaded_fields( array $fields, Form $form ): array {
if ( $form->get_identifier() !== 'yourproject_person' ) {
return $fields;
}
foreach ( $fields as $field ) {
if ( $field->get_identifier() === 'status_label' ) {
$field->set_value( strtoupper( (string) $field->get_value() ) );
}
}
return $fields;
}