community-forum icon indicating copy to clipboard operation
community-forum copied to clipboard

[Feature Request] Use labeller for create / update forms

Open julienmru opened this issue 4 years ago • 2 comments
trafficstars

Feature Request

What's the feature you think Backpack should have?

I'm using CRUD::setLabeller to automatically set labels according to a custom function which translates the technical field names (in English) in my database schema to a user-friendly localized name.

Have you already implemented a prototype solution, for your own project?

No.

Do you see this as a core feature or an add-on?

Core feature. In my opinion CRUD::setLabeller should label anything. I'm not sure if it's a bug or a feature that it doesn't label create/update forms :)

julienmru avatar Nov 14 '21 07:11 julienmru

Hello there! Thanks for opening your first issue on this repo!

Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.

Backpack communication channels:

  • Bug Reports, Feature Requests - Github Issues (here);
  • Quick help (How do I do X) - Gitter Chatroom;
  • Long questions (I have done X and Y and it won't do Z wtf) - Stackoverflow, using the backpack-for-laravel tag;
  • Showing off something you've made, asking for opinion on Backpack/Laravel matters - Reddit;

Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.

Thank you!

-- Justin Case The Backpack Robot

welcome[bot] avatar Nov 14 '21 07:11 welcome[bot]

I implemented similar functionality:

namespace App\Library\Backpack;

use Backpack\CRUD\app\Library\CrudPanel\CrudPanel as BackpackCrudPanel;

class CrudPanel extends BackpackCrudPanel
{
    ...

    protected function makeSureFieldHasLabel($field)
    {
        if (!isset($field['label'])) {
            $name = is_array($field['name']) ? $field['name'][0] : $field['name'];
            $field['label'] = mb_ucfirst($this->makeLabel($name));
        }

        return $field;
    }

    ...
}

devpreview avatar Dec 16 '21 19:12 devpreview