The existing code that I am working with provides a drop-down for the end
user to select a time zone.
My goal is to limit the choices down to
1. America
and
a. Option Eastern
value America/New_York
b. Option Central
value America/Chicago
c. Option Mountain DST
value America/Denver
d. Option Mountain no DST
value America/Phoenix
e. Option Pacific
value America/Los_Angeles
Narrowing it down to America was easy enough by simply commenting out the code.
Narrowing it down further to the 5 time zones is turning out to be beyond my pay grade.
Any advice?
$regions = [
# 'Africa' => DateTimeZone::AFRICA,
'America' => DateTimeZone::AMERICA,
# 'Antarctica' => DateTimeZone::ANTARCTICA,
# 'Aisa' => DateTimeZone::ASIA,
# 'Atlantic' => DateTimeZone::ATLANTIC,
# 'Europe' => DateTimeZone::EUROPE,
# 'Indian' => DateTimeZone::INDIAN,
# 'Pacific' => DateTimeZone::PACIFIC
];
$timezones = [];
foreach ($regions as $name => $mask) {
$zones = DateTimeZone::listIdentifiers($mask);
foreach ($zones as $timezone) {
$timezones[$name][$timezone] = $timezone;
}
}
$actualTimezone = JFactory::getSession()->get('user-timezone', $displayData['dateHelper']->getDate()->getTimezone()->getName(), 'Calendar');
?>
<form action="<?php echo JUri::base(); ?>" method="get" class="dp-timezone dp-form">
<span class="dp-timezone__label">
<?php echo $displayData['translator']->translate('COM_CALENDAR_CHOOSE_TIMEZONE'); ?>:
</span>
<select name="tz" class="dp-select dp-timezone__select">
<option value="UTC"<?php $actualTimezone == 'UTC' ? ' selected' : ''; ?>>
<?php echo $displayData['translator']->translate('JLIB_FORM_VALUE_TIMEZONE_UTC'); ?>
</option>
<?php foreach ($timezones as $region => $list) { ?>
<?php foreach ($list as $timezone => $name) { ?>
<option value="<?php echo $timezone; ?>"<?php echo $actualTimezone == $timezone ? ' selected' : ''; ?>>
<?php echo $displayData['translator']->translate($name); ?>
</option>
<?php } ?>
<?php } ?>
</select>
<input type="hidden" name="task" value="profile.tz" class="dp-input dp-input-hidden">
<input type="hidden" name="option" value="com_calendar" class="dp-input dp-input-hidden">
<input type="hidden" name="view" value="profile" class="dp-input dp-input-hidden">
<input type="hidden" name="return" value="<?php echo base64_encode(JUri::getInstance()->toString()); ?>" class="dp-input dp-input-hidden">
</form>
Related
I would like the view the country list, state list and city list in the layout side menu in all the pages.
<div class="container side-menu">
<div class="row">
<div class="col-md-3">
<?php $countries = array();?>
<select class="form-control">
<option value="">All</option>
<?php foreach($countries as $country) { ?>
<?php echo "<option>".$country['name']."</option>"; ?>
<?php } ?>
</select>
</div>
<div class="col-md-3">
<?php $categories = array(); ?>
<select class="form-control">
<option value="">All</option>
<?php foreach($categories as $category) { ?>
<?php echo "<option>".$category['name']."</option>"; ?>
<?php } ?>
</select>
</div>
I'm new to html and php and so on... Just self studying some things. Now I have a little problem with this form (inside of "auswahlmenue.php"):
<form action="liste.php" method="post">
Mitarbeiter
<select name="mitarbeiter">
<?php
// SQL-Query erzeugen
require "sql.php";
$sql01 = "SELECT NAME FROM felder ORDER BY name";
$result = mysql_query($sql01);
// für jeden Eintrag ein Option-Tag erstellen
while ($row = mysql_fetch_array($result)) {
echo '<option value="'.$row['ID'].'"'.($_POST['NAME'] == $row['ID'] ? " selected": "").'>'.$row['NAME'].'</option>';
}
?>
</select>
<input type="submit" value="Senden" />
</form>
Everything works fine. I see my dropdown list and I can select my name... Now I want to check my selection at this page (liste.php):
<?require "auswahlmenue.php";if(isset($_POST['mitarbeiter']) ) {$listemid=$_POST["mitarbeiter"];echo "Test $listenmid";}else {echo "Es wurden keine Werte übergeben";}?>
It doesn't print out my variable $listenmid... What am I getting wrong?
Thank you very much for your help...
There is a select2 element :
<select name="commande_id" id="commande">
<option value=""> -- Choisir une commande -- </option>
<option value="1">COM-2-2015</option>
</select>
$(document).ready(function() {
...
$("#commande").select2({width:'100%'});
...
});
When I enter the page in update mode then I set the option value of the select element programmatically to be the value from database :
$(document).ready(function() {
...
<?php
if (isset($data)) { ?>
...
$("#commande").val("<?php echo $data[0]['commande_id'];?>");
...
<?php
}
?>
...
});
The problem is that at runtime the select element does not show the appropriate text :
But when I click it then the appropriate value is selected :
So how to make the appropriate text shown ?
I don't know how you are getting the $data, but I guess it's something like that, just an example:
<?php
$data[] = ["commande_id" => "1", "name_field" => "COM-2-2015"];
foreach ($data as $key => $value){
?>
<select>
<option value='<?php echo $value['commande_id']?>'><?php echo $value['name_field'] ?></option>
</select>
<?php } ?>
Look it here: https://ideone.com/PSpKmu
I want to group the form fields like field set or simply enclosed by div. My form needs to be look like below
<form>
<div class="step-1">
Field 1
Field 2
</div>
<div class="step-2">
Field 3
Field 4
</div>
</form>
Graphical example :
Edit : Form class added for reference!
class ProfileForm extends BaseProfileForm
{
public function configure()
{
..... // other widget configuration
$this->embedForm('media', new MediaForm());
}
}
How can I do this in symfony form?
For example:
In action:
$this->form = new MyCoolForm()
In templates:
<form name="form name" id="MyCoolForm" action="<?php echo url_for('action_url') ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
<?php echo $form['name']->render() ?>
<?php echo $form['name']->renderError(); ?>
<fieldset>
<legend>Ppassword:</legend>
<?php echo $form['password']->render() ?>
<?php echo $form['password']->renderError(); ?>
<?php echo $form['password_again']->render() ?>
<?php echo $form['password_again']->renderError(); ?>
<fieldset>
<?php echo $form->renderHiddenFields(); ?>
</form>
etc...
this is the index action and template generated at the backend for the
model "coche".
public function executeIndex(sfWebRequest $request)
{
// sorting
if ($request->getParameter('sort') &&
$this->isValidSortColumn($request->getParameter('sort')))
{
$this->setSort(array($request->getParameter('sort'),
$request->getParameter('sort_type')));
}
// pager
if ($request->getParameter('page'))
{
$this->setPage($request->getParameter('page'));
}
$this->pager = $this->getPager();
$this->sort = $this->getSort();
}
This is the index template:
<?php use_helper('I18N', 'Date') ?>
<?php include_partial('coche/assets') ?>
<div id="sf_admin_container">
<h1><?php echo __('Coche List', array(), 'messages') ?></h1>
<?php include_partial('coche/flashes') ?>
<div id="sf_admin_header">
<?php include_partial('coche/list_header', array('pager' => $pager)) ?>
</div>
<div id="sf_admin_bar">
<?php include_partial('coche/filters', array('form' => $filters,
'configuration' => $configuration)) ?>
</div>
<div id="sf_admin_content">
<form action="<?php echo url_for('coche_coche_collection',
array('action' => 'batch')) ?>" method="post">
<?php include_partial('coche/list', array('pager' => $pager, 'sort' =>
$sort, 'helper' => $helper)) ?>
<ul class="sf_admin_actions">
<?php include_partial('coche/list_batch_actions', array('helper' =>
$helper)) ?>
<?php include_partial('coche/list_actions', array('helper' => $helper)) ?>
</ul>
</form>
</div>
<div id="sf_admin_footer">
<?php include_partial('coche/list_footer', array('pager' => $pager)) ?>
</div>
</div>
In the template there is this line:
include_partial('coche/filters', array('form' => $filters,
'configuration' => $configuration)) ?>
but i can not find the variables $this->filters and $this->configuration in the
index action.
How is that possible?
Javi
Is the index action extending a class? If yes, that's how!
It looks like a module generated by admin generator. If it's so, then these vars are set in autoCocheActions class which resides in project cache and is generated on the fly.