Skip to content

Commit

Permalink
Adding Textarea Field when choosing LongText
Browse files Browse the repository at this point in the history
  • Loading branch information
AkramChauhan committed May 11, 2024
1 parent b232bd4 commit 37f92ab
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
33 changes: 32 additions & 1 deletion app/Console/Commands/MakeModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ public function handle() {
$ajax_header_lines = [];
$ajax_body_lines = [];
$manage_body_lines = [];
$manage_script_lines = [];
if (count($col_names) >= 1) {
// Define the new lines you want to replace with
foreach ($col_data as $col) {
Expand All @@ -193,7 +194,34 @@ public function handle() {
}
$new_line .= ";";
array_push($new_lines, $new_line);
$manage_body_line = '<div class="col-md-6">
if ($col_type == "longText") {
$manage_body_line = '<div class="col-md-12">
<div class="mb-3">
<label for="' . $col['name'] . '">' . snakeToNormal($col['name']) . '</label>
<textarea
name="' . $col['name'] . '"
rows="10" class="form-control tiny-cloud-editor k-input"
id="' . $col['name'] . '"
aria-describedby="' . $col['name'] . 'Help">@if($edit){{$data->' . $col['name'] . '}}@else{{old(' . $col_name_copy . ')}}@endif</textarea>
<small id="' . $col['name'] . 'Help" class="form-text text-muted"></small>
</div>
</div>';
$manage_script_lines = <<<EOD
\n@push("scripts")
<script src="https://cdn.tiny.cloud/1/rjcn06xon4v0snhiv3rvotq9163xs47zt4tx0sdp6izhg8o3/tinymce/6/tinymce.min.js" referrerpolicy="origin"></script>
<script>
tinymce.init({
selector: ".tiny-cloud-editor",
skin: "bootstrap",
plugins: "lists, link, image, media",
toolbar: "h1 h2 h3 h4 h5 | fontfamily fontsize | bold italic strikethrough blockquote | align lineheight bullist numlist backcolor | link ",
menubar: false,
});
</script>
@endpush
EOD;
} else {
$manage_body_line = '<div class="col-md-6">
<div class="mb-3">
<label for="' . $col['name'] . '">' . snakeToNormal($col['name']) . '</label>
<input
Expand All @@ -210,6 +238,8 @@ class="form-control k-input"
<small id="' . $col['name'] . 'Help" class="form-text text-muted"></small>
</div>
</div>';
}

array_push($manage_body_lines, $manage_body_line);
}

Expand Down Expand Up @@ -254,6 +284,7 @@ class="form-control k-input"
implode("\n ", $manage_body_lines),
$stubContent
);
$stubContent .= $manage_script_lines;
}
// Copy the modified content to the blade file
file_put_contents($fullViewPath, $stubContent);
Expand Down
21 changes: 20 additions & 1 deletion resources/views/backend/pages/manage.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@
<small id="nameHelp" class="form-text text-muted"></small>
</div>
</div>
<div class="col-md-12">
<div class="mb-3">
<label for="content">Content</label>
<textarea name="content" rows="10" class="form-control tiny-cloud-editor k-input" id="content" aria-describedby="contentHelp">@if($edit){{$data->name}}@else{{old('name')}}@endif</textarea>
<small id="contentHelp" class="form-text text-muted"></small>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
Expand All @@ -66,4 +73,16 @@
</div>
</div>
</div>
@endsection
@endsection
@push("scripts")
<script src="https://cdn.tiny.cloud/1/rjcn06xon4v0snhiv3rvotq9163xs47zt4tx0sdp6izhg8o3/tinymce/6/tinymce.min.js" referrerpolicy="origin"></script>
<script>
tinymce.init({
selector: '.tiny-cloud-editor',
skin: 'bootstrap',
plugins: 'lists, link, image, media',
toolbar: 'h1 h2 h3 h4 h5 | fontfamily fontsize | bold italic strikethrough blockquote | align lineheight bullist numlist backcolor | link ',
menubar: false,
});
</script>
@endpush

0 comments on commit 37f92ab

Please sign in to comment.