Jump to content
MakeWebGames

Need extra set of eyes


Sim

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by Dayo
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...