Generators icon indicating copy to clipboard operation
Generators copied to clipboard

Command to create a new field:

Open tabacitu opened this issue 5 years ago • 6 comments

php artisan backpack:field {name}

tabacitu avatar Apr 20 '20 07:04 tabacitu

Hi there!

Is this still an issue? No activity in 60 days. I'm going to mark it as stale for now, and close it in 14 days if no further activity occurs. I know you guys are all busy, but if this is important to you please reply or something, so I know not to close it.

Thank you!

-- Justin Case The Backpack Robot

stale[bot] avatar Jun 20 '20 17:06 stale[bot]

Hi there!

Is this still an issue? No activity in 60 days. I'm going to mark it as stale for now, and close it in 14 days if no further activity occurs. I know you guys are all busy, but if this is important to you please reply or something, so I know not to close it.

Thank you!

-- Justin Case The Backpack Robot

stale[bot] avatar Aug 22 '20 19:08 stale[bot]

Hi there!

Is this still an issue? No activity in 60 days. I'm going to mark it as stale for now, and close it in 14 days if no further activity occurs. I know you guys are all busy, but if this is important to you please reply or something, so I know not to close it.

Thank you!

-- Justin Case The Backpack Robot

stale[bot] avatar Nov 01 '20 07:11 stale[bot]

Hi there!

Is this still an issue? No activity in 60 days. I'm going to mark it as stale for now, and close it in 14 days if no further activity occurs. I know you guys are all busy, but if this is important to you please reply or something, so I know not to close it.

Thank you!

-- Justin Case The Backpack Robot

stale[bot] avatar Jun 26 '21 03:06 stale[bot]

bump

pxpm avatar Jul 02 '21 07:07 pxpm

Hi there!

Is this still an issue? No activity in 60 days. I'm going to mark it as stale for now, and close it in 14 days if no further activity occurs. I know you guys are all busy, but if this is important to you please reply or something, so I know not to close it.

Thank you!

-- Justin Case The Backpack Robot

stale[bot] avatar Jan 08 '22 22:01 stale[bot]

@karandatwani92 any chance you can take this on, too?

tabacitu avatar Aug 30 '22 07:08 tabacitu

@tabacitu Yes, noted. We will have it soon.

karandatwani92 avatar Aug 30 '22 07:08 karandatwani92

@tabacitu I'm thinking of two types of action for field, column, filter & widget:

  • php artisan backpack:field {name} for new plain file
  • php artisan backpack:field {name} --backpack_field_name to copy view file with new name in case one wants modify and use if for own purpose as i did with webcam field?

what do you say?

karandatwani92 avatar Aug 30 '22 13:08 karandatwani92

I love it. But let's name the second one:

php artisan backpack:field {name} --from={source_field_name}

That should be easier to read, right?

tabacitu avatar Aug 30 '22 14:08 tabacitu

Now that I think about it... a new empty file doesn't really make sense at all... You'd have to code everything from scratch... so perhaps a good starting point would be the text field.

You specify no --from => it creates it from TEXT You specify a --from => it creates it from whatever you chose

What do you think @karandatwani92 ? Without an example... it would be really difficult to create a proper custom field. And I guess text is the best example.

tabacitu avatar Aug 30 '22 14:08 tabacitu

My two cents here:

php artisan backpack:field {name} --from="any_field"

  • Copy the provided field. Nothing to see here.

php artisan backpack:field {name}

  • Create the field file from a stub similar to the text input but without all the suffix, hint, prefix stuff ... if you want text, use --from="text"
@include(wrapper_start)
<input type="text" />
@include(wrapper_end)

php artisan backpack:field {name}--withAssets

@include(wrapper_start)
<input type="text" data-init-function="bpFieldInitMyFieldElement" />
@include(wrapper_end)

@push('crud_fields_styles')
  @loadOnce('your_field_name_field_style')
    <style>
        .your_field_class { display: none; }
    </style>
  @endLoadOnce
@endpush

@push('crud_fields_scripts')
  @loadOnce(asset('myFieldScript.js')

@loadOnce('bpFieldInitMyFieldElement')
    function bpFieldInitMyFieldElement(element) {
    // element is the jquery wrapped element where init function is defined. 
    }
@endLoadOnce

@endpush

Even the empty stubs show alot on how the Backpack fields are structured, for me, much more understandable than looking at current field implementations and figure out the "story" on why things are there.

Cheers

pxpm avatar Aug 30 '22 14:08 pxpm

Hmm... fair enough. Ok, I'm convinced, let's do it Pedro's way!

tabacitu avatar Aug 30 '22 14:08 tabacitu

@tabacitu Please check. #144

karandatwani92 avatar Sep 07 '22 09:09 karandatwani92

Whoohooo! Let's move the conversation to https://github.com/Laravel-Backpack/Generators/pull/144 then 🎉 We're making progress!!!

tabacitu avatar Sep 08 '22 09:09 tabacitu