Skip to content
Snippets Groups Projects

Validate text length on lockup text fields

Merged Tyler R Lemburg requested to merge feature/issue-3 into develop

Because of developer laziness and not a great need, we weren't doing this before. However it is good to ensure that we hold to standards that we set, so we're putting this into play. Javascript validation occurs and the server checks as well, on create and edit processes.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
240 $lockup_model->acronym_subject = strtoupper($post_params['acronym_subject']);
241 $lockup_model->extension_county = $post_params['extension_county'];
242 $lockup_model->style = $post_params['type'];
243 $lockup_model->user_id = \Auth::$current_user->id;
244 $lockup_model->date_created = date('Y-m-d H:i:s');
245 $lockup_model->status = Lockup::AWAITING_APPROVAL;
246 $lockup_model->creative_status = Lockup::AWAITING_APPROVAL;
247 $lockup_model->preview_svg = $svg_text;
248 $lockup_model->vert_preview_svg = $vert_svg_text;
249 $lockup_model->approver_id = empty($post_params['approver']) ? NULL : $post_params['approver'];
250 $lockup_model->file_organization = $post_params['file_organization'];
251 $lockup_model->file_organization_acronym = $post_params['file_organization_acronym'];
252 $lockup_model->file_department = $post_params['file_department'];
253 $lockup_model->file_department_acronym = $post_params['file_department_acronym'];
254
255 $valid = TRUE;
  • It looks like this block of validation code is used (copied) in a couple of places. It might be a better idea to centralize this as a method of the Lockup model class.

  • Kevin Abel
    Kevin Abel @kabel2 started a thread on the diff
  • 14 \Core::$breadcrumbs[] = array('text' => 'Create Lockup');
    15
    16 $context = new \stdClass;
    17 $context->lockup = new Lockup;
    18 $context->approvers = User::find('all', array('conditions' => array('role' => 'approver')));
    19 return self::renderView('new_lockup', $context);
    20 }
    21
    22 public static function editAction($get_params) {
    23 self::requireAuth();
    24 \Core::$breadcrumbs[] = array('text' => 'Edit Lockup');
    25
    26 if (empty($get_params['id'])) {
    27 \Core::notFound();
    13 private static function checkTextFieldLength($params, $field, $max_length) {
    14 if (strlen($params[$field]) > $max_length) {
    • This may not be a huge deal, but this is not multi-byte character safe. If someone uses non-ASCII characters, the length will be wrong.

  • Tyler R Lemburg Added 2 commits:

    Added 2 commits:

    • 6860840d - Change data-max-length attribute to use standard maxlength
    • 74b6aee2 - Insert tabindex -1 for error message
  • Tyler R Lemburg Status changed to merged

    Status changed to merged

  • Tyler R Lemburg mentioned in commit d910c69f

    mentioned in commit d910c69f

  • Please register or sign in to reply
    Loading