Hi Mitul, first of all let me tell you thanks, for this package, is so helpfull, the second i try to customice the $FIELD_INPUT$ generators but i can't becouse no exist a file or template, can let me change this.
I try to change in your FormFieldsGenerator, but no is the good way, i create a Gist , i hope you can think in one solution for this.
This is the Gist. I Modified the FormFieldsGenerator,
'col-sm-2 control-label']) !!}";
$template = str_replace('$FIELD_NAME_TITLE$', $label, $template);
$template = str_replace('$FIELD_NAME$', $field['fieldName'], $template);
return $template;
}
private static function replaceFieldVars($textField, $field)
{
$label = Str::title(str_replace("_", " ", $field['fieldName']));
$textField = str_replace('$FIELD_NAME$', $field['fieldName'], $textField);
$textField = str_replace('$FIELD_NAME_TITLE$', $label, $textField);
$textField = str_replace('$FIELD_INPUT$', $textField, $textField);
return $textField;
}
public static function text($templateData, $field)
{
$textField = self::generateLabel($field);
$textField .= '
';
$textField .= "\n\t{!! Form::text('\$FIELD_NAME\$', null, ['class' => 'form-control']) !!}";
$textField .= '
';
$templateData = str_replace('$FIELD_INPUT$', $textField, $templateData);
$templateData = self::replaceFieldVars($templateData, $field);
return $templateData;
}
public static function textarea($templateData, $field)
{
$textareaField = self::generateLabel($field);
$textareaField .= '
';
$textareaField .= "\n\t{!! Form::textarea('\$FIELD_NAME\$', null, ['class' => 'form-control']) !!}";
$textareaField .= '
';
$templateData = str_replace('$FIELD_INPUT$', $textareaField, $templateData);
$templateData = self::replaceFieldVars($templateData, $field);
return $templateData;
}
public static function password($templateData, $field)
{
$textField = self::generateLabel($field);
$textField .= '
';
$textField .= "\n\t{!! Form::password('\$FIELD_NAME\$', ['class' => 'form-control']) !!}";
$textField .= '
';
$templateData = str_replace('$FIELD_INPUT$', $textField, $templateData);
$templateData = self::replaceFieldVars($templateData, $field);
return $templateData;
}
public static function email($templateData, $field)
{
$textField = self::generateLabel($field);
$textField .= '
';
$textField .= "\n\t{!! Form::email('\$FIELD_NAME\$', null, ['class' => 'form-control']) !!}";
$textField .= '
';
$templateData = str_replace('$FIELD_INPUT$', $textField, $templateData);
$templateData = self::replaceFieldVars($templateData, $field);
return $templateData;
}
public static function file($templateData, $field)
{
$textField = self::generateLabel($field);
$textField .= '
';
$textField .= "\n\t{!! Form::file('\$FIELD_NAME\$') !!}";
$textField .= '
';
$templateData = str_replace('$FIELD_INPUT$', $textField, $templateData);
$templateData = self::replaceFieldVars($templateData, $field);
return $templateData;
}
public static function checkbox($templateData, $field)
{
$textField = "
\n";
$textField .= "\t\t";
$textField .= "{!! Form::checkbox('\$FIELD_NAME\$', 1, true) !!}";
$textField .= "\$FIELD_NAME_TITLE\$";
$textField .= " ";
$textField .= "\n\t
";
$templateData = str_replace('$FIELD_INPUT$', $textField, $templateData);
$templateData = self::replaceFieldVars($templateData, $field);
return $templateData;
}
public static function radio($templateData, $field)
{
$textField = self::generateLabel($field);
if (sizeof($field['typeOptions']) > 0) {
$arr = explode(",", $field['typeOptions']);
foreach ($arr as $item) {
$label = Str::title(str_replace("_", " ", $item));
$textField .= "\n\t
";
$textField .= "\n\t\t";
$textField .= "\n\t\t\t{!! Form::radio('gender', '" . $item . "', null) !!} $label";
$textField .= "\n\t\t ";
$textField .= "\n\t
";
}
}
$templateData = str_replace('$FIELD_INPUT$', $textField, $templateData);
$templateData = self::replaceFieldVars($templateData, $field);
return $templateData;
}
public static function number($templateData, $field)
{
$textField = self::generateLabel($field);
$textField .= '
';
$textField .= "\n\t{!! Form::number('\$FIELD_NAME\$', null, ['class' => 'form-control']) !!}";
$textField .= '
';
$templateData = str_replace('$FIELD_INPUT$', $textField, $templateData);
$templateData = self::replaceFieldVars($templateData, $field);
return $templateData;
}
public static function date($templateData, $field)
{
$textField = self::generateLabel($field);
$textField .= '
';
$textField .= "\n\t{!! Form::date('\$FIELD_NAME\$', null, ['class' => 'form-control']) !!}";
$textField .= '
';
$templateData = str_replace('$FIELD_INPUT$', $textField, $templateData);
$templateData = self::replaceFieldVars($templateData, $field);
return $templateData;
}
public static function select($templateData, $field)
{
$textField = self::generateLabel($field);
$textField .= "
";
$textField .= "{!! Form::select('\$FIELD_NAME\$', \$INPUT_ARR\$, null, ['class' => 'form-control']) !!}";
$textField .= '
';
$textField = str_replace('$FIELD_NAME$', $field['fieldName'], $textField);
if (sizeof($field['typeOptions']) > 0) {
$arr = explode(",", $field['typeOptions']);
$inputArr = '[';
foreach ($arr as $item) {
$inputArr .= " '$item' => '$item',";
}
$inputArr = substr($inputArr, 0, strlen($inputArr) - 1);
$inputArr .= " ]";
$textField = str_replace('$INPUT_ARR$', $inputArr, $textField);
} else {
$textField = str_replace('$INPUT_ARR$', '[]', $textField);
}
$templateData = str_replace('$FIELD_INPUT$', $textField, $templateData);
$templateData = self::replaceFieldVars($templateData, $field);
return $templateData;
}
```
}