Making objectHTMLSafe work
Posted: Mon Mar 03, 2008 9:58 pm
Could use some help with my coding. I'm trying to get a textarea to save html code to my mysql database. Can anyone tell me how to set this up?
Thanks!
Thanks!
Joomla! Community, help and support.
https://sandbox-forum.joomla.org/
Code: Select all
<?php defined('_JEXEC') or die('Restricted access');?>
<form action="index.php" method="post" name="adminForm" id="adminForm">
<div class="col100">
<fieldset class="adminform">
<legend><?php echo JText::_( 'Details' ); ?></legend>
<table class="admintable">
<tr>
<td width="100" align="right" class="key">
<label for="title">
<?php echo JText::_( 'Title' ); ?>:
</label>
</td>
<td>
<input class="text_area" type="text" name="title" id="title" size="32" maxlength="250" value="<?php echo $this->recipe->title;?>" />
</td>
</tr>
<tr>
<td width="100" align="right" class="key">
<label for="ingredients">
<?php echo JText::_( 'Ingredients' ); ?>:
</label>
</td>
<td>
<textarea class="inputbox" cols="70" rows="10" name="ingredients" id="ingredients"><?php echo $this->recipe->ingredients;?></textarea>
</td>
</tr>
</table>
<table class="adminform">
<tr>
<td width="100" align="right" class="key">
<label for="directions">
<?php echo JText::_( 'Directions' ); ?>:
</label>
</td>
<td>
<textarea id="directions" name="directions" cols="75" rows="20" style="width:100%; height:550px;" class="mce_editable="><?php echo $this->recipe->directions;?></textarea>
<div id="editor-xtd-buttons">
<div class="button2-left"><div class="image"><a class="modal-button" title="Image" href="http://www.kernandlead.com/~russell/administrator/index.php?option=com_media&view=images&tmpl=component&e_name=text" rel="{handler: 'iframe', size: {x: 570, y: 400}}">Image</a></div></div>
<div class="button2-left"><div class="pagebreak"><a class="modal-button" title="Pagebreak" href="http://www.kernandlead.com/~russell/administrator/index.php?option=com_content&task=ins_pagebreak&tmpl=component&e_name=text" rel="{handler: 'iframe', size: {x: 400, y: 85}}">Pagebreak</a></div></div>
<div class="button2-left"><div class="readmore"><a title="Read more..." href="http://www.kernandlead.com/~russell/administrator/#" onclick="insertReadmore('text');return false;" rel="">Read more...</a></div></div>
</div>
</td>
</tr>
</table>
</fieldset>
</div>
<div class="clr"></div>
<input type="hidden" name="option" value="com_recipe" />
<input type="hidden" name="id" value="<?php echo $this->recipe->id; ?>" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="controller" value="recipe" />
</form>
Code: Select all
$data = JRequest::get( 'post' );
$data['ingredients'] = JRequest::getVar( 'ingredients, '', 'post', 'string', JREQUEST_ALLOWRAW );
// Bind the form fields to the table
if (!$row->bind($data)) {
$this->setError($this->_db->getErrorMsg());
return false;
}
// Make sure the record is valid
if (!$row->check()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
// Store the content to the database
if (!$row->store()) {
$this->setError( $row->getErrorMsg() );
return false;
}
return true;
Code: Select all
/**
* save a record (and redirect to main page)
* @return void
*/
function save()
{
$data = JRequest::get( 'post' );
$data['directions'] = JRequest::getVar( 'directions', '', 'post', 'string', JREQUEST_ALLOWRAW );
// Bind the form fields to the table
if (!$row->bind($data)) {
$this->setError($this->_db->getErrorMsg());
return false;
}
// Make sure the record is valid
if (!$row->check()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
// Store the content to the database
if (!$row->store()) {
$this->setError( $row->getErrorMsg() );
return false;
}
return true;
$model = $this->getModel('recipe');
if ($model->store($post)) {
$msg = JText::_( 'Recipe Saved!' );
} else {
$msg = JText::_( 'Error Saving Recipe' );
}
// Check the table in so it can be edited.... we are done with it anyway
$link = 'index.php?option=com_recipe';
$this->setRedirect($link, $msg);
}
Code: Select all
$data['directions'] = JRequest::getVar( 'directions', '', 'post', 'string', JREQUEST_ALLOWRAW );