Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Commit

Permalink
ISAICP-6550: Fix get created date validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
saidatom committed Aug 25, 2021
1 parent f8e6d2d commit 211ef4b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
1 change: 0 additions & 1 deletion tests/features/asset_release/add_asset_release.feature
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ Feature: "Add release" visibility options.
And I go to "/rdf_entity/http_e_f_fexample1regression/asset_release/add"
Then I should see the heading "Page not found"

@javascript
Scenario: Check publish time release is present time and past.
Given the following owner:
| name | type |
Expand Down
4 changes: 2 additions & 2 deletions tests/src/Context/JoinupContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ public function printMessages() {
* Fills a date or time field at a datetime widget.
*
* Examples:
* - When I fill in "Start date" with the date "29-08-2016".
* - When I fill in "Start date" with the date "2016-08-29".
* - When I fill in "Start date" with the date "+2 days".
* - When I fill in "Start date" with the time "26:59:00".
* - When I fill in "Start date" with the time "+1 hour".
Expand All @@ -885,7 +885,7 @@ public function fillDateField(string $field_group, string $date_component, strin
$is_relative_value = $date_component === 'date' ? preg_match('/^\d{2}-\d{2}-\d{4}$/', $value) === 0 : preg_match('/^\d{2}:\d{2}:\d{2}$/', $value) === 0;

if ($is_relative_value) {
$value = date('d-m-Y', strtotime($value));
$value = date('Y-m-d', strtotime($value));
}

$field_selectors = $this->findDateFields($field_group);
Expand Down
3 changes: 2 additions & 1 deletion web/modules/custom/asset_release/asset_release.module
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ function asset_release_form_alter(&$form, FormStateInterface $form_state, string
*/
function _asset_release_edit_date_validate(array &$form, FormStateInterface $form_state): void {
$dt_now = new DateTime();
$date_value = $form_state->getValue('created')[0]['value'];
$values = $form_state->getValues();
$date_value = $values['created'][0]['value'];
if ($date_value->format('c') > $dt_now->format('c')) {
$form_state->setErrorByName('created', t('Your "Authored on" field date is greater than @date', ['@date' => $dt_now->format('c')]));
}
Expand Down

0 comments on commit 211ef4b

Please sign in to comment.