Sim Posted July 28, 2020 Share Posted July 28, 2020 I don't know what I did but now my save button disappears. I think it's a problem with the HTML. PHP: $html = $this->page->buildElement("form", $data); debug($html); $html = str_replace("(extraHTML)", $itemType->getAdminHTML(), $html); HTML Part #1: public $form = ' <center><b>{stepMessage}</b><center> <form method="post" action="?page=admin&module=items&action={editType}&id={id}" enctype="multipart/form-data"> <input type="hidden" name="extraData" id="extra" value="{extraData}"> <div class="formid-group"> <label class="pull-left">Name</label> <input type="text" class="form-control" name="name" value="{name}"> </div> <div class="form-group"> <label class="pull-left">Desc:</label> <input type="text" class="form-control" name="desc" value="{desc}"> </div> <div class="form-group"> <label class="pull-left">Image</label> <input class="form-control" type="file" name="file" id="file" /> </div> <div class="form-group"> <label class="pull-left">Resize Image Height to:</label> <input type="number" class="form-control" name="height" value="{height}"> </div> <div class="form-group"> <label class="pull-left">Reize Image Width to:</label> <input type="number" class="form-control" name="width" value="{width}"> </div> <div class="form-group"> <label class="pull-left">Price $$</label> <input type="number" class="form-control" name="price" value="{price}"> </div> <div class="form-group"> <label class="pull-left">Cost ({_setting "pointsName"}):</label> <input type="number" class="form-control" name="points" value="{points}"> </div> <div class="form-group"> <label class="pull-left">Item Types Allowed> (Note: If you want these item types to be attached to this item slot)</label> <select class="form-control" name="itemTypes[]" id="itemTypes[]" size="10" multiple="multiple"> <option value="0">None</option> {#each itemType} <option value="{id}" {selected}>{name}</option> {/each} </select> </div> <div class="form-group"> <label class="pull-left">Value (ex: damage, armour, health, bonus, ect.)</label> <input type="number" class="form-control" name="value" value="{value}"> </div> <div class="form-group"> <label class="pull-left">Slot Spaces(How many spot spaces does this item take up)</label> <input type="number" class="form-control" name="slots" value="{slots}"> </div> (extraHTML) <div class="text-right"> <button class="btn btn-default" name="submit" type="submit" value="1">Save</button> </div> test test test test test test text me when you get a chance can you send me the link to the video of the day and I will be there in a few minutes to talk to you about it when I get home I will send you the link to the video of the day and I will be there in a few minutes to talk </form> '; PART #2: //returns additional admin HTML if needed for adding/edit this item type public function getAdminHTML() { global $helper; $items = $helper->getItems(); $itemList = ""; foreach($items as $item) { $itemList .= '<option value="' . $item["id"] . '">' . $item["name"] . '</option> '; } $html = ' <div class="form-group"> <label class="pull-left">#Of Items To Grant</label> <input type="text" class="form-control" name="count" value="{count}"> </div> <div class="form-group"> <label class="pull-left">Select items that can be randomly given: </label> <select class="form-control" name="items[]" id="items[]" size="10" multiple="multiple"> <option value="0">None</option> ' . $itemList . ' </select> </div> '; return $html; } EVERYTHING after (extraHTML) gets removed. So I'm thinking that there's something wrong with the HTML tags in getAdminHTML Quote Link to comment Share on other sites More sharing options...
InverTed Posted July 28, 2020 Share Posted July 28, 2020 (edited) It doesnt look like anything there is the issue, so yeah i think your issue lies elsewhere. Edited July 28, 2020 by InverTed Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted July 29, 2020 Share Posted July 29, 2020 Do any of your item names contain a closing bracket? Quote Link to comment Share on other sites More sharing options...
Dayo Posted July 29, 2020 Share Posted July 29, 2020 Quick question why don’t you use <{extraHTML}> ? Quote Link to comment Share on other sites More sharing options...
Sim Posted July 29, 2020 Author Share Posted July 29, 2020 4 hours ago, Dayo said: Quick question why don’t you use <{extraHTML}> ? What does <{extraHTML}> do? The < >? $extra = $itemType->getAdminHTML(); $html = $this->page->buildElement("form", $data); $html = str_replace("(extraHTML)", $extra, $html); return $this->html .= $html; Funny this works though. Quote Link to comment Share on other sites More sharing options...
Dayo Posted July 30, 2020 Share Posted July 30, 2020 (edited) 17 hours ago, Sim said: What does <{extraHTML}> do? The < >? $extra = $itemType->getAdminHTML(); $html = $this->page->buildElement("form", $data); $html = str_replace("(extraHTML)", $extra, $html); return $this->html .= $html; $extra = $itemType->getAdminHTML(); $html = $this->page->buildElement("form", $data); $html = str_replace("(extraHTML)", $extra, $html); return $this->html .= $html; Funny this works though. <{var}> enables you to pass HTML to the template so you could do something like <?php $data["extraHTMLVar"] = $itemType->getAdminHTML(); $this->html .= $this->page->buildElement("form", $data); //in .tpl.php you add this where you want to display html <{extraHTMLVar}> check this out https://github.com/ChristopherDay/Gangster-Legends-V2/wiki/Templating#variable-formatting Edited July 30, 2020 by Dayo Quote Link to comment Share on other sites More sharing options...
Sim Posted July 30, 2020 Author Share Posted July 30, 2020 I did try that after you mentioned it, but all it did was replace the <{extraHTML}> with nothing's. Funny, cause there's a thread in here somewhere created by me months ago asking how to include HTML from a variable into the template and we finally got an answer in another thread. What version is this supported in? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.