Skip to content

Commit

Permalink
Update BS5 required form elements #1687
Browse files Browse the repository at this point in the history
  • Loading branch information
phalene-bytes committed Oct 28, 2023
1 parent 4ec24ec commit 181d96a
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected function addField($name)
switch ($name) {
case 'authorizedFormOfName':
$this->form->setDefault('authorizedFormOfName', $this->resource['authorizedFormOfName']);
$this->form->setValidator('authorizedFormOfName', new sfValidatorString());
$this->form->setValidator('authorizedFormOfName', new sfValidatorString(['required' => true]));
$this->form->setWidget('authorizedFormOfName', new sfWidgetFormInput());

break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@
<?php echo render_field(
$form->date
->help(__('Accession date represents the date of receipt of the materials and is added during the donation process.'))
->label(__('Acquisition date').' <span class="form-required" title="'.__('This is a mandatory element.').'">*</span>'),
->label(__('Acquisition date')),
null,
['type' => 'date']
); ?>

<?php echo render_field($form->sourceOfAcquisition
->help(__('Identify immediate source of acquisition or transfer, and date and method of acquisition IF the information is NOT confidential.'))
->label(__('Immediate source of acquisition').' <span class="form-required" title="'.__('This is a mandatory element.').'">*</span>'), $resource, ['class' => 'resizable']); ?>
->label(__('Immediate source of acquisition')), $resource, ['class' => 'resizable']); ?>

<?php echo render_field($form->locationInformation
->help(__('A description of the physical location in the repository where the accession can be found.'))
->label(__('Location information').' <span class="form-required" title="'.__('This is a mandatory element.').'">*</span>'), $resource, ['class' => 'resizable']); ?>
->label(__('Location information')), $resource, ['class' => 'resizable']); ?>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,24 @@
<div id="deaccession-collapse" class="accordion-collapse collapse" aria-labelledby="deaccession-heading">
<div class="accordion-body">
<?php echo render_field($form->identifier
->label(__('Deaccession number').' <span class="form-required" title="'.__('This is a mandatory element.').'">*</span>')
->label(__('Deaccession number'))
); ?>

<?php echo render_field($form->scope
->help(__('Identify if the whole accession is being deaccessioned or if only a part of the accession is being deaccessioned.'))
->label(__('Scope').' <span class="form-required" title="'.__('This is a mandatory element.').'">*</span>')
->label(__('Scope'))
); ?>

<?php echo render_field(
$form->date->help(__('Date of deaccession'))->label(
__('Date')
.' <span class="form-required" title="'
.__('This is a mandatory element.')
.'">*</span>'
),
<?php echo render_field($form->date
->help(__('Date of deaccession'))
->label(__('Date')),
null,
['type' => 'date']
); ?>

<?php echo render_field($form->description
->help(__('Identify what materials are being deaccessioned.'))
->label(__('Description').' <span class="form-required" title="'.__('This is a mandatory element.').'">*</span>'), $resource, ['class' => 'resizable']); ?>
->label(__('Description')), $resource, ['class' => 'resizable']); ?>

<?php echo render_field($form->extent
->help(__('The number of units as a whole number and the measurement of the records to be deaccessioned.')), $resource, ['class' => 'resizable']); ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<div id="identity-collapse" class="accordion-collapse collapse" aria-labelledby="identity-heading">
<div class="accordion-body">
<?php echo render_field($form->authorizedFormOfName
->label(__('Authorized form of name').' <span class="form-required" title="'.__('This is a mandatory element.').'">*</span>'), $resource); ?>
->label(__('Authorized form of name')), $resource); ?>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<div id="identity-collapse" class="accordion-collapse collapse" aria-labelledby="identity-heading">
<div class="accordion-body">
<?php echo render_field($form->authorizedFormOfName
->label(__('Authorized form of name').' <span class="form-required" title="'.__('This is a mandatory element.').'">*</span>'), $resource); ?>
->label(__('Authorized form of name')), $resource); ?>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ protected function addField($name)

$this->form->setWidget('date', new sfWidgetFormInput());
$this->form->setValidator('date', new sfValidatorDate([
'required' => true,
'date_format' => '/^(?P<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2})$/',
'date_format_error' => 'YYYY-MM-DD',
]));
Expand Down Expand Up @@ -272,18 +273,24 @@ protected function addField($name)

case 'appraisal':
case 'archivalHistory':
case 'locationInformation':
case 'physicalCharacteristics':
case 'processingNotes':
case 'receivedExtentUnits':
case 'scopeAndContent':
case 'sourceOfAcquisition':
$this->form->setDefault($name, $this->resource[$name]);
$this->form->setValidator($name, new sfValidatorString());
$this->form->setWidget($name, new sfWidgetFormTextarea());

break;

case 'sourceOfAcquisition':
case 'locationInformation':
$this->form->setDefault($name, $this->resource[$name]);
$this->form->setValidator($name, new sfValidatorString(['required' => true]));
$this->form->setWidget($name, new sfWidgetFormTextarea());

break;

case 'informationObjects':
$criteria = new Criteria();
$criteria->add(QubitRelation::OBJECT_ID, $this->resource->id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected function addField($name)
switch ($name) {
case 'scope':
$this->form->setDefault('scope', $this->context->routing->generate(null, [$this->resource->scope, 'module' => 'term']));
$this->form->setValidator('scope', new sfValidatorString());
$this->form->setValidator('scope', new sfValidatorString(['required' => true]));

$choices = [];
$choices[null] = null;
Expand All @@ -103,6 +103,11 @@ protected function addField($name)
break;

case 'description':
$this->form->setDefault($name, $this->resource[$name]);
$this->form->setValidator($name, new sfValidatorString(['required' => true]));
$this->form->setWidget($name, new sfWidgetFormTextarea());

break;
case 'extent':
case 'reason':
$this->form->setDefault($name, $this->resource[$name]);
Expand All @@ -121,6 +126,7 @@ protected function addField($name)

$this->form->setWidget('date', new sfWidgetFormInput());
$this->form->setValidator('date', new sfValidatorDate([
'required' => true,
'date_format' => '/^(?P<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2})$/',
'date_format_error' => 'YYYY-MM-DD',
]));
Expand All @@ -129,7 +135,7 @@ protected function addField($name)

case 'identifier':
$this->form->setDefault($name, $this->resource[$name]);
$this->form->setValidator($name, new sfValidatorString());
$this->form->setValidator($name, new sfValidatorString(['required' => true]));
$this->form->setWidget($name, new sfWidgetFormInput());

break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected function addField($name)
switch ($name) {
case 'authorizedFormOfName':
$this->form->setDefault('authorizedFormOfName', $this->resource->authorizedFormOfName);
$this->form->setValidator('authorizedFormOfName', new sfValidatorString());
$this->form->setValidator('authorizedFormOfName', new sfValidatorString(['required' => true]));
$this->form->setWidget('authorizedFormOfName', new sfWidgetFormInput());

break;
Expand Down

0 comments on commit 181d96a

Please sign in to comment.