name = 'radio'; $this->label = 'Radio Button'; $this->category = 'choice'; } public function render( $field, $value = '', $name = null ) { $name = $name ?: "metaforge[{$field['name']}]"; $layout = isset( $field['layout'] ) ? $field['layout'] : 'vertical'; $group_class = ( $layout === 'horizontal' ) ? 'mfe-choice-layout-horizontal' : 'mfe-choice-layout-vertical'; echo '
'; echo ''; echo '
'; if ( ! empty( $field['options'] ) && is_array( $field['options'] ) ) { foreach ( $field['options'] as $key => $label ) { $display_label = ( $key === $label || ( strpos( $label, '_' ) !== false && strpos( $label, ' ' ) === false ) ) ? ucwords( str_replace( '_', ' ', $label ) ) : $label; $is_checked = ( $value === (string) $key ) ? 'checked' : ''; echo ''; } } else { echo 'No options configured.'; } echo '
'; echo '
'; } }