question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Field definition should include field size and separate html attributes

See original GitHub issue

Aurel Drăguţ came with a great idea in order to allow developers to build 2-column layouts, 3-column layouts, etc in their forms.

Just by allowing the developer to place an extra class on the parent form element

<div class='form-group'>

we would be able to easily build panels that look like this: screen shot 2016-06-09 at 09 57 50

This would imply a certain syntax change, so the change should come at the same with @cristiantone 's proposition to separate the HTML attributes sent to the input/textarea/select/etc.

Here’s the new proposed syntax for the “text” field type:

$this->crud->addFields([
  // mandatory
  'name' => 'name',
  'type' => 'text',
  'label' => 'Name',
  // optional
  'optionalAttributes' => [
    'disabled' => 'disabled',
    'style' => 'border: 1px solid red',
    ...
  ],
  'parentAttributes' => [
     'class' => 'col-md-6',
     'style' => 'border-top: 1px solid #eee; margin-top: 10px;'
  ]
]);

@Ghitu , @cristiantone , @mariusconstantin2503 , what do you think?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
tabacitucommented, Jul 22, 2016

Done. Works in CRUD 2.1 like this:

$this->crud->addFields([
  // mandatory
  'name' => 'name',
  'type' => 'text',
  'label' => 'Name',
  // optional
  'attributes' => [
    'disabled' => 'disabled',
    'style' => 'border: 1px solid red',
    ...
  ],
  'wrapperAttributes' => [
     'class' => 'col-md-6',
     'style' => 'border-top: 1px solid #eee; margin-top: 10px;'
  ]
]);
0reactions
Simpson1993commented, Mar 28, 2017

But if I want to change custom field width? … write new field type?)

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML attribute: pattern - HTML: HyperText Markup Language
The pattern attribute specifies a regular expression the form control's value should match. If a non-null value doesn't conform to the ...
Read more >
HTML Input Attributes - W3Schools
The input size attribute specifies the visible width, in characters, of an input field. The default value for size is 20. Note: The...
Read more >
Forms in HTML documents - W3C
An HTML form is a section of a document containing normal content, markup, special elements called controls (checkboxes, radio buttons, menus, etc.), and...
Read more >
Dictionary attributes - Product Documentation | ServiceNow
Name Value Target Element allow_null true/false field_name field allow_public true/false table_name field allow_references true/false field_name field
Read more >
What are attributes in computing? - TechTarget
The style attribute is used to add different styles to an HTML element, such as color, font or size. Example. <p style="color:purple;"> This...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found