grafiteinc / forms Goto Github PK
View Code? Open in Web Editor NEWForm Classes for Laravel - letting you generate HTML forms from PHP Classes
Home Page: https://docs.grafite.ca/utilities/forms/
License: Other
Form Classes for Laravel - letting you generate HTML forms from PHP Classes
Home Page: https://docs.grafite.ca/utilities/forms/
License: Other
FormMaker::fromTable('users') shows user all field that's ok .
But i want show only selected fields .
I knew @input_maker method for custom form but it is time consuming
Thanks...
Hi,
Im passing details from database as object, all of the form fields fills up correctly except the drop downs, they just get populated with possible options but value from database isnt getting selected.
This is my code,
{!! FormMaker::fromObject($patient,
$columns = $inputs,
$view = 'user._input',
$class = '',
$populated = true,
$reformatted = false,
$idAndTimestamps = false) !!}
$inputs is array of inputs being passed from the trait to controller to this view.
below is how i have setup the select dropdown in input trait.
'bloodgroup' =>[
'type' => 'select',
'class' => 'col-xs-10 col-sm-5',
'alt_name' => 'Blood Group',
'options' => [
'unknown' => 'unknown',
'A+' => 'A+',
'B+' => 'B+',
'O+' => 'O+',
'AB+' => 'AB+',
'A-' => 'A-',
'B-' => 'B-',
'O-' => 'O-',
'AB-' => 'AB-',
]
I should have messed up somewhere, please point me in right direction.
Thanks
Im working with laracogs.
here is the error im getting:
snippet im using::
@input_maker_create('meta[phone]', ['type' => 'string'], $user)
result im getting::
<input id="Meta[phone]" class="form-control" name="meta[phone]" value="{" id":1,"user_id":1,"phone":null,"is_active":1,"activation_token":"59afc4ace32e7a6b8b3d8e69d1659f05","marketing":0,"terms_and_cond":1,"created_at":"2017-01-19="" 11:47:44","updated_at":"2017-01-19="" 11:47:44"}"="" placeholder="Meta Phone" type="text">
As you can see, I want the value from phone field from meta table to populate the table, instead chaotic is going on in here!!
I have this config:
'in_promotion' => [
'type' => 'checkbox',
'class' => 'flat-green',
],
And the generated input haven't the flat-green
class that i set
<div class="form-group ">
<label class="control-label" for="In_promotion">In_promotion</label>
<input id="In_promotion" name="in_promotion" type="checkbox">
</div>
Currently in FormMaker, the behavior gets the information of a table and creates a form based on the information gathered.
For my project, I have multiple data sources to pull from so I have multiple connections that I want to be able to create cruds for. That being the case, I need to be able to specify the connection.
public function fromTable(
$table,
$columns = null,
$class = 'form-control',
$view = null,
$reformatted = true,
$populated = false,
$idAndTimestamps = false,
$connection = null
)
This would probably be an ideal signature to avoid breaking earlier versions.
The following line will work exactly the same with this new signature, but will use a different schema if connection is defined.
$tableColumns = Schema::connection($connection)->getColumnListing($table);
I am using the standard User - Roles relationship tables as set up by default in Quarx.
When I try to use formMaker to show existing roles on the user edit screen I get the following error:
[2018-04-16 16:14:24] local.ERROR: Call to undefined method Illuminate\Database\Query\Builder::roles() (View: C:\wamp\www\proj\resources\views\admin\users\edit.blade.php)
Here is my edit blade file:
{!! FormMaker::fromObject($user,
[
'name',
'meta[first_name]' => [
'alt_name' => 'First Name',
],
'meta[roles]' => [
'alt_name' => 'Roles',
'custom' => 'multiple',
'multiple' => true,
'class' => auth()->user(),
'method' => 'roles',
'type' => 'relationship',
'model' => 'App\Models\Role',
'label' => 'label', // the field for the label in the select input generated
'value' => 'name' // the field for the label in the select input generated
],
] ) !!}
{!! Form::submit('Update', ['class' => 'btn btn-primary pull-right']) !!}
{!! Form::close() !!}
If I remove the method
and class
attributes then it shows the multi select but all of the options are selected by default:
'meta[roles]' => [
'alt_name' => 'Roles',
'custom' => 'multiple',
'multiple' => true,
'type' => 'relationship',
'model' => 'App\Models\Role',
'label' => 'label', // the field for the label in the select input generated
'value' => 'name' // the field for the label in the select input generated
]
Not sure what's going on here, I am using "yab/laracogs": "^2.3",
v1.0.8 of FormMaker has a syntax error on line 70, where $connection is misspelled when passed in as an argument. It's fixed in origin/master, but when composer requires FormMaker as a dependency for laracogs, it asks for the broken version. I can't submit a pull requests for tag changes, so it'll have to be fixed by YABhq, something like this:
I have the following in a blade template....
@form_maker_object(
$package_item->package_meta_data,
Cms::moduleConfig('package_items', 'form')
)
the package_meta_data
attribute is a ValueObject class object with an attributes
property which is accessed via magic methods. i.e. __get()
__set()
the Cms::moduleConfig('package_items', 'form')
consists of an associate array having the attributes of the said ValueObject class and input configurations.
e.g.
'form' => [
'package_name' => [],
'package_description' => [
'type' => 'text'
],
'package_price' => [
'type' => 'number'
],
'package_vendor' => [],
'package_notes' => [
'type' => 'text'
],
'package_ref_id' => [
'type' => 'hidden'
],
'meta_package_length' => [
'type' => 'number',
'alt_name' => 'Package Length'
],
however when rending the form fields in edit mode the fields are blank.
What is the case here if the object has property values?
A toggle field
I have the following inside a blade file:
@input_maker('category', [ 'type' => 'relationship', 'model' => 'App\Models\Category', 'label' => 'name', 'value' => 'id'
That throws an error saying that options are required. To reproduce the error, the categories table must be empty, when I add at least one row to the table the error stop appearing.
use ziptastic to set city and country?
using the formArray()
function. how does one set a default or initial entered value of a field?
formArray([
...
birth_date' => [
'type' => 'input',
'objectValue' => 'sample Test' // I would have expected 'value' => 'default set value'
],
...
]);
objectValue
does not seem to add a "value"
to the generated field input.
By using the HTML pattern attribute there could be an easy way to integrate regex based validations to mirror many of the Laravel based validation rules.
Packages and notes for help later:
https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/pattern
https://github.com/lucleroy/php-regex
https://laravel.com/docs/7.x/validation
There should be an attribute to define individual input IDs, at least for checkbox and radio inputs. I found this problem trying to define two radio buttons with the same name, so the user could choose one or another option. The problem is that they consecuently inherit the name as ID, and that's not right.
public function makeRadio($config, $selected, $custom)
{
return '<input ' . $custom . ' id="' . ucfirst($config['name']) . '" ' . $selected . ' type="radio" name="' . $config['name'] . '">';
}
yab/formmaker/src/Generators/HtmlGenerator.php
Steps to reproduce
Try create a label such as <label for="job_number">Job Number</label>
with input_maker_label
Expected
A way to create a label with a different name to the input ID that is linked with for attribute
For example
input_maker_label('input_id', ['label' => 'Label Name'])
or input_maker_label('Label Name', ['for' => 'input_id'])
outputting
<label for="input_id">label name</label>
Actual
With InputMaker->label you are forced to make the name the same as the for=".." attribute, which cannot be overridden.
<label for="input_id">input_id</label>
Or am I missing something? I see no alternative in the source code or documentation.
Thanks.
Add a means of setting the file accept type attribute for file uploads.
In my Model i add the proprety $dates
for convert automatically the my timestamps to Carbon object and after this i get a error.
protected $dates = ['created_at', 'updated_at', 'deleted_at', 'from_ts', 'to_ts'];
What i'm get:
ErrorException in InputCalibrator.php line 56: Object of class Carbon\Carbon could not be converted to int (View: D:\serverpath\dev2016\yabhq-laracogs\www\laracogs\resources\views\pricelist\periods\edit.blade.php)
<button id="capture">Capture</button>
<canvas id="canvas" width="320" height="240"></canvas>
<script>
const player = document.getElementById('player');
const canvas = document.getElementById('canvas');
const context = canvas.getContext('2d');
const captureButton = document.getElementById('capture');
const constraints = {
video: true,
};
captureButton.addEventListener('click', () => {
// Draw the video frame to the canvas.
context.drawImage(player, 0, 0, canvas.width, canvas.height);
});
// Attach the video stream to the video element and autoplay.
navigator.mediaDevices.getUserMedia(constraints).then((stream) => {
player.srcObject = stream;
});
</script>```
Migrate each of these fields to the newer pattern for next version change
Given this:
@input_maker_create('product', ['type' => 'select', 'options' => $productDropDownListItems])
Where $productDropDownListItems
outputs an array of options
[
1 => 'Load',
5 => 'Labels'
]
If the user selects labels... how do tell the input_maker_create
to make value=5
as the selected value? I haven't found any examples or any docs referencing this specifically.
Thanks in advance!
There is a method for create form from table and get an object or array of fields, copy it and after edit for my needs with more options that it allow.
In this way i first generate an object/array from table
After i copy this array/object and edit it for my fits
In the end i have an array genarated and edited from what i generate the final form.
Thank in advance! Cheer
Hello,
I might be missing something obvious here but i can't seem to get a 'value' for a checkbox using InputMaker
eg.
{{ Form::checkbox('published', true) }}
will give me
<input name="published" type="checkbox" value="1">
while
@input_maker_create('published', ['type' => 'checkbox'], $foo)
outputs
<input id="Published" type="checkbox" name="published">
Hi there guys,
I bought a bootstrap theme and have been using it with Laracogs. I recently came across the select element and can't seem to generate a select element that uses the theme within blade.
This is because when I use @foreach directive I can't seem to be able to create a roles selection. I can only achieve it using the default installation and normal bootstrap.
Regards
Currently if the model has soft delete enabled, then the form renders deleted_at field also as date input
desired behaviour if the model has soft delete enabled then, deleted_at column should be counted as bad_column and should not include it in form.
@input_maker_create('meta[phone]', ['type' => 'string'], $user)
Update working but, does not show in the input element.
Currently Laracogs eager loads the model of whatever relationship it's presented with. i.e.
@input_maker_label('Store')
@input_maker_create('stores', ['type' => 'relationship', 'model' => 'App\Repositories\Store\Store', 'label' => 'name', 'value' => 'id'], $user)
I'm looking for a way to limit what's loaded into the model somehow. Any ideas on how to go about this?
Old values are not been retained on nested arrays / forms
I could be wrong but this seems to be due to the fact that the method refineConfigs() seems to be checking for 'name' but the nested array will be array['name']
$inputConfig['inputs'][$name]
This can be recreated by running a fresh laravel install and laracogs starter.
On /user/settings add a phone number and delete the name or email and save.
The phone number will be lost.
A field for handling tags/keywords
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.