foreach ( $fields as $key => $value ) {
if ( $value instanceof HTMLFormField ) {
- $v = empty( $value->mParams['nodata'] )
+ $v = isset( $this->mFieldData[$key] )
? $this->mFieldData[$key]
: $value->getDefault();
$fieldData = [];
foreach ( $this->mFlatFields as $fieldname => $field ) {
- if ( !empty( $field->mParams['nodata'] ) ) {
+ $request = $this->getRequest();
+ if ( $field->skipLoadData( $request ) ) {
continue;
} elseif ( !empty( $field->mParams['disabled'] ) ) {
$fieldData[$fieldname] = $field->getDefault();
} else {
- $fieldData[$fieldname] = $field->loadDataFromRequest( $this->getRequest() );
+ $fieldData[$fieldname] = $field->loadDataFromRequest( $request );
}
}
return $this->msg( $value, [] );
}
}
+
+ /**
+ * Skip this field when collecting data.
+ * @param WebRequest $request
+ * @return bool
+ * @since 1.27
+ */
+ public function skipLoadData( $request ) {
+ return !empty( $this->mParams['nodata'] );
+ }
}
$subrequest = new DerivativeRequest( $request, $data, $request->wasPosted() );
$row = [];
foreach ( $fields as $fieldname => $field ) {
- if ( !empty( $field->mParams['nodata'] ) ) {
+ if ( $field->skipLoadData( $subrequest ) ) {
continue;
} elseif ( !empty( $field->mParams['disabled'] ) ) {
$row[$fieldname] = $field->getDefault();
$fields = $this->createFieldsForKey( $key );
foreach ( $fields as $fieldname => $field ) {
- $v = ( empty( $field->mParams['nodata'] ) && $values !== null )
+ $v = isset( $values[$fieldname] )
? $values[$fieldname]
: $field->getDefault();
protected $buttonType = 'submit';
protected $mFlags = [ 'primary', 'constructive' ];
+
+ public function skipLoadData( $request ) {
+ return !$request->getCheck( $this->mName );
+ }
+
+ public function loadDataFromRequest( $request ) {
+ return $request->getCheck( $this->mName );
+ }
}