Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field definition should include field size and separate html attributes #30

Closed
tabacitu opened this issue Jun 9, 2016 · 6 comments
Closed
Milestone

Comments

@tabacitu
Copy link
Member

tabacitu commented Jun 9, 2016

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?

@tabacitu tabacitu added this to the 2.1 milestone Jun 9, 2016
@tabacitu
Copy link
Member Author

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;'
  ]
]);

@tabacitu tabacitu modified the milestones: 3.0, 2.1 Jul 28, 2016
@nilsE
Copy link

nilsE commented Aug 4, 2016

thanks!
are attributes / wrapperAttributes also possible for column fields? that would be great.

@tabacitu
Copy link
Member Author

tabacitu commented Aug 5, 2016

Hi @nilsE ,

Nope, column fields don't have any attributes on them. My thought was that if you need to add some attributes, you probably need some HTML too. So then it's just easier to create a new column type.

I could be wrong though, how would you have used the column attributes if they were there?

Cheers.

@nilsE
Copy link

nilsE commented Aug 5, 2016

@tabacitu I think you're right, i played around a little with columns and created my own custom type, it's very flexible this way. And there's the $column object so i can use my own attributes in the column definition and template, e.g. {{$column['label_class']}}

btw: after poking around with many laravel boilerplates, crud generators and even cms frameworks i ended up using backpack for my actual project and i'm VERY happy with it!

@tabacitu
Copy link
Member Author

tabacitu commented Aug 5, 2016

:-) I'm very glad to hear that. Really. Seeing people using the packages is the only thing that makes this worthwhile. Cheers!

@Simpson1993
Copy link

Simpson1993 commented Mar 28, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants