SetFormActionScript
Описание и параметры
void SetFormActionScript( string actionScript );
Метод устанавливает значение атрибута action формы мастера (тега <form>). По умолчанию атрибут action равен адресу текущей страницы.
Параметры
| Параметр | Описание |
|---|---|
| actionScript | Значения атрибута name |
Смотрите также
Примеры использования
<?
if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
class FirstStep extends CWizardStep
{
function InitStep()
{
$this->SetTitle("Первый шаг");
$this->SetStepID("first");
$this->SetNextStep("second");
$this->SetCancelStep("fourth");
}
function ShowStep()
{
$this->content .= "Введите код: ".$this->ShowInputField("text", "code", Array("size" => "15"));
}
}
class SecondStep extends CWizardStep
{
function InitStep()
{
$wizard =& $this->GetWizard();
$this->SetTitle("Второй шаг");
$this->SetStepID("second");
$this->SetNextStep("third");
$this->SetPrevStep("first");
$this->SetCancelStep("fourth");
}
}
class ThirdStep extends CWizardStep
{
function InitStep()
{
$this->SetTitle("Третий шаг");
$this->SetStepID("third");
$this->SetNextStep("fourth");
$this->SetCancelStep("fourth");
}
}
class FourthStep extends CWizardStep
{
function InitStep()
{
$this->SetTitle("Четвертый шаг");
$this->SetStepID("fourth");
$this->SetNextStep("fourth");
}
function ShowStep()
{
$wizard =& $this->GetWizard();
//На этом шаге форма мастера будет отправлена по адресу /index.php
$wizard->SetFormActionScript("/index.php");
}
}
class MyPinkTemplate extends CWizardTemplate
{
function GetLayout()
{
$wizard =& $this->GetWizard();
$obStep =& $wizard->GetCurrentStep();
$wizardName = htmlspecialcharsEx($wizard->GetWizardName());
//Получаем ошибки
$arErrors = $obStep->GetErrors();
$strError = "";
if (count($arErrors) > 0)
{
foreach ($arErrors as $arError)
$strError .= $arError[0]."<br />";
$strError = '<tr><td style="padding-top: 10px; padding-left: 20px; color:red;">'.$strError.'</td></tr>';
}
//Заголовок и подзаголовок
$stepTitle = $obStep->GetTitle();
$stepSubTitle = $obStep->GetSubTitle();
return <<<HTML
{#FORM_START#}
<table style="border:2px outset #D4D0C8; background-color: #FFDEDE;" border="0" cellpadding="0" cellspacing="0" height="370" width="100%">
<tr>
<td style="background-color: #142F73" height="1"><span style="color:white; font-weight:bold; text-align:left; padding-left: 2px;">{$wizardName}</span></td>
</tr>
<tr>
<td style="height: 60px; border-bottom:2px groove #aca899; background-color: #FFC4C4; padding: 8px;" valign="top">
<div style="padding-top: 5px; padding-left: 20px;"><b>{$stepTitle}</b></div>
<div style="padding-left: 40px;">{$stepSubTitle}</div>
</td>
</tr>
{$strError}
<tr>
<td style="padding: 20px; padding-left: 28px;padding-right: 28px;" valign="top" id="wizard-content-area">{#CONTENT#}</td>
</tr>
<tr>
<td style="background-color: #FFC4C4; height: 40px; border-top:2px groove #ffffff; padding-right: 15px;" align="right">{#BUTTONS#}</td>
</tr>
</table>
{#FORM_END#}
<script type="text/javascript">
function WizardOnLoad()
{
var cancelButton = document.forms["my_form"].elements["cancel_button"];
var nextButton = document.forms["my_form"].elements["next_button"];
var prevButton = document.forms["my_form"].elements["prev_button"];
var finishButton = document.forms["my_form"].elements["finish_button"];
if (cancelButton && !nextButton && !prevButton && !finishButton)
cancelButton.onclick = CloseWindow;
else if(cancelButton)
cancelButton.onclick = ConfirmCancel;
}
function CloseWindow()
{
window.location = '/';
return false;
}
function ConfirmCancel()
{
return (confirm("Вы действительно хотите прервать мастер?"));
}
WizardOnLoad();
</script>
HTML;
}
}
//Создаем мастер
$wizard = new CWizardBase("Работа с идентификаторами формы мастера", $package);
$wizard->SetTemplate(new MyPinkTemplate);
//Устанавливаем атрибут name форме мастера
$wizard->SetFormName("my_form");
//Устанавливаем кнопкам навигации атрибут name
$wizard->SetPrevButtonID("prev_button");
$wizard->SetNextButtonID("next_button");
$wizard->SetFinishButtonID("finish_button");
$wizard->SetCancelButtonID("cancel_button");
//Устанавливаем префикс переменным мастера
$wizard->SetVarPrefix("my_prefix_");
//Добавляем шаги
$wizard->AddSteps(Array("FirstStep", "SecondStep", "ThirdStep", "FourthStep"));
//Выводим
$wizard->Display();
?>
© «Битрикс», 2001-2025, «1С-Битрикс», 2025