adamwathan / bootforms

Rapid form generation with Bootstrap 3 and Laravel.
MIT License
417 stars 103 forks source link

Add attribute with '-' caracter #111

Closed PeaX10 closed 7 years ago

PeaX10 commented 8 years ago

Please can you add this to allow people to add attribute like data-live-search or other like this: Bootform::text('Field', 'name')->data_live_search(true);

File : src/AdamWathan/Form/Elements/Element.php

protected function splitKeysAndValues($array)
    {
        // Disgusting crap because people might have passed a collection
        $keys = [];
        $values = [];

        foreach ($array as $key => $value) {
            $keys[] = str_replace('_', '-', $key);
            $values[] = $value;
        }

        return [$keys, $values];
    }

Thx !
joelcuevas commented 8 years ago

Aren't these methods useful for you?

Bootform::text('Field', 'name')->data('live-search', true);

Or, with the same result:

Bootform::text('Field', 'name')->attribute('data-live-search', true);
adamwathan commented 7 years ago

Yep use the data helpers like mentioned above.