MyBB Community Forums

Full Version: What does generate_file_upload_box do?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
I'm customizing a plugin myself. I saw Form class with generate_file_upload_box function. I couldn't find it. So what does this function do? What's the parameters and return?
Thanks.
Note: I think plugin documentation is less than i expected. I think there should be something like files for X is in Y folder etc..
where did you see this ?
(2018-10-18, 05:12 PM)Ashley1 Wrote: [ -> ]where did you see this ?

In newpoints shop plugin. Also other mybb plugins have it too. You can see it by searching google. So i am sure it is in core files of mybb.
admin/inc/class_form.php

	/**
	 * Generate a file upload field.
	 *
	 * @param string $name The name of the file upload field.
	 * @param array $options Array of options for the file upload field (class, id, style)
	 * @return string The generated file upload field.
	 */
	function generate_file_upload_box($name, $options=array())
	{
		$input = "<input type=\"file\" name=\"".$name."\"";
		if(isset($options['class']))
		{
			$input .= " class=\"text_input ".$options['class']."\"";
		}
		else
		{
			$input .= " class=\"text_input\"";
		}
		if(isset($options['style']))
		{
			$input .= " style=\"".$options['style']."\"";
		}
		if(isset($options['id']))
		{
			$input .= " id=\"".$options['id']."\"";
		}
		$input .= " />";
		return $input;

	}
generate_file_upload_box is part of the ACP's HTML generators. As Ashley1 noted above, the form methods are found in admin/inc/class_form.php and the table methods are found in admin/inc/class_table.php

These methods (there are many) can be used when building HTML for page display in the ACP.

$form = new Form('index.php', 'post', 'elementId', false, 'elementName', false, 'onSubmit JavaScript');
$form->generate_file_upload_box('inputName', array('id' => 'inputId', 'class' => 'myClass', 'style' => 'you css here'));
$form->end();

Will output something like this:

<form action="index.php" method="post" id="elementId" name="elementName" onsubmit="doSomethingInJS();">
	<input type="file" name="inputName" id="inputId" class="myClass" />
</form>
Thanks. There are other classes too. I've been finding 'em.
(2018-10-18, 06:14 PM)tvman99 Wrote: [ -> ]Thanks. There are other classes too. I've been finding 'em.

Cool
mybboard.de maintain a handy cross-reference for MyBB functions and classes that might be useful: https://crossreference.mybb.de/nav.html?...s.php.html
(2018-10-18, 09:22 PM)Euan T Wrote: [ -> ]mybboard.de maintain a handy cross-reference for MyBB functions and classes that might be useful: https://crossreference.mybb.de/nav.html?...s.php.html

This is very useful. That is what i am looking for. 
Thanks.